Skip to content

Commit

Permalink
perf: fix deopt during mapping
Browse files Browse the repository at this point in the history
  • Loading branch information
dougwilson committed Jun 8, 2015
1 parent 95130f6 commit baef846
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 7 deletions.
5 changes: 5 additions & 0 deletions HISTORY.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
unreleased
==========

* perf: fix deopt during mapping

2.1.0 / 2015-06-07
==================

Expand Down
16 changes: 9 additions & 7 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -167,20 +167,22 @@ function populateMaps(extensions, types) {
extensions[type] = exts

// extension -> mime
exts.forEach(function forEachExtension(ext) {
if (types[ext]) {
var from = preference.indexOf(db[types[ext]].source)
for (var i = 0; i < exts.length; i++) {
var extension = exts[i]

if (types[extension]) {
var from = preference.indexOf(db[types[extension]].source)
var to = preference.indexOf(mime.source)

if (types[ext] !== 'application/octet-stream'
&& from > to || (from === to && types[ext].substr(0, 12) === 'application/')) {
if (types[extension] !== 'application/octet-stream'
&& from > to || (from === to && types[extension].substr(0, 12) === 'application/')) {
// skip the remapping
return
}
}

// set the extension -> mime
types[ext] = type
})
types[extension] = type
}
})
}

0 comments on commit baef846

Please sign in to comment.