- Notifications
You must be signed in to change notification settings - Fork20.5k
Commit8633fc7
committed
Avoid reading outside of collection bounds
Consider the following collection: const array = ['a', 'b', 'c'];Retrieving `array[0]` can be done relatively quickly. However, when the property doesn’t exist on the receiver, JavaScript engines must continue to look up the prototype chain until either the property is found or the chain ends. This is inherently slower than *not* doing any prototype chain lookups. Retrieving an out-of-bounds index, e.g. `array[3]`, triggers this scenario, resulting in decreased performance.This patch changes the way the `cleanData` loop is written to avoid running into the slow case unnecessarily.1 parent692f9d4 commit8633fc7
1 file changed
+3
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
285 | 285 | | |
286 | 286 | | |
287 | 287 | | |
| 288 | + | |
288 | 289 | | |
289 | 290 | | |
290 | | - | |
| 291 | + | |
| 292 | + | |
291 | 293 | | |
292 | 294 | | |
293 | 295 | | |
| |||
0 commit comments
Comments
(0)