Commit 14c0a9b
committed
perf(@schematics/angular): optimize AST traversal utilities
Improves the performance of AST utility functions by reducing redundant work and memory allocations.
- The `findNodes` function is now memoized with a `WeakMap`-based cache. This prevents repeated traversals of the entire source file AST when searching for nodes of the same kind, which is a common pattern.
- The `getSourceNodes` function has been refactored to use a single array instead of two, reducing memory overhead and avoiding costly `shift()` operations.1 parent 0a450ca commit 14c0a9b
1 file changed
+27
-11
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
90 | 90 | | |
91 | 91 | | |
92 | 92 | | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
93 | 98 | | |
94 | 99 | | |
95 | 100 | | |
| |||
137 | 142 | | |
138 | 143 | | |
139 | 144 | | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
140 | 153 | | |
141 | 154 | | |
142 | 155 | | |
| |||
157 | 170 | | |
158 | 171 | | |
159 | 172 | | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
160 | 182 | | |
161 | 183 | | |
162 | 184 | | |
| |||
167 | 189 | | |
168 | 190 | | |
169 | 191 | | |
170 | | - | |
171 | | - | |
172 | | - | |
173 | | - | |
174 | 192 | | |
175 | | - | |
176 | | - | |
177 | | - | |
178 | | - | |
179 | | - | |
180 | | - | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
181 | 197 | | |
182 | 198 | | |
183 | | - | |
| 199 | + | |
184 | 200 | | |
185 | 201 | | |
186 | 202 | | |
| |||
0 commit comments