Skip to content

Commit baef846

Browse files
committed
perf: fix deopt during mapping
1 parent 95130f6 commit baef846

File tree

2 files changed

+14
-7
lines changed

2 files changed

+14
-7
lines changed

HISTORY.md

+5
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
unreleased
2+
==========
3+
4+
* perf: fix deopt during mapping
5+
16
2.1.0 / 2015-06-07
27
==================
38

index.js

+9-7
Original file line numberDiff line numberDiff line change
@@ -167,20 +167,22 @@ function populateMaps(extensions, types) {
167167
extensions[type] = exts
168168

169169
// extension -> mime
170-
exts.forEach(function forEachExtension(ext) {
171-
if (types[ext]) {
172-
var from = preference.indexOf(db[types[ext]].source)
170+
for (var i = 0; i < exts.length; i++) {
171+
var extension = exts[i]
172+
173+
if (types[extension]) {
174+
var from = preference.indexOf(db[types[extension]].source)
173175
var to = preference.indexOf(mime.source)
174176

175-
if (types[ext] !== 'application/octet-stream'
176-
&& from > to || (from === to && types[ext].substr(0, 12) === 'application/')) {
177+
if (types[extension] !== 'application/octet-stream'
178+
&& from > to || (from === to && types[extension].substr(0, 12) === 'application/')) {
177179
// skip the remapping
178180
return
179181
}
180182
}
181183

182184
// set the extension -> mime
183-
types[ext] = type
184-
})
185+
types[extension] = type
186+
}
185187
})
186188
}

0 commit comments

Comments
 (0)