Skip to content

vue-doctor/performance/js-index-maps ​

Build a Map indexed by the search key before the loop for O(1) lookups

PropertyValue
CategoryPerformance
Default Severitywarning
Confidencemedium
FixableNo
Engineoxlint
Sincev1.0.0
Frameworksvue, nuxt
Test filesNot checked (which files)

Why it matters ​

Build a Map indexed by the search key before the loop for O(1) lookups

How to fix ​

Review the finding and update the code according to best practices below.

Agent Guidance ​

Reported when a loop searches the same array on every iteration with a key-equality predicate (find(x => x.id === id)). Build a Map keyed by that field once before the loop and use map.get(key) instead. Searches whose array changes per iteration, or whose predicate is not a key comparison, are left alone.


Rule source: vue-doctor/performance/js-index-maps

Released under the MIT License.