source-map
Advanced tools
Comparing version 0.1.42 to 0.1.43
# Change Log | ||
## 0.1.43 | ||
* Performance improvements for `SourceMapGenerator` and `SourceNode`. See issue | ||
#148 for some discussion and issues #150, #151, and #152 for implementations. | ||
## 0.1.42 | ||
@@ -4,0 +9,0 @@ |
@@ -105,5 +105,4 @@ /* -*- Mode: js; js-indent-level: 2; -*- */ | ||
smc.__generatedMappings = aSourceMap._mappings.slice() | ||
.sort(util.compareByGeneratedPositions); | ||
smc.__originalMappings = aSourceMap._mappings.slice() | ||
smc.__generatedMappings = aSourceMap._mappings.toArray().slice(); | ||
smc.__originalMappings = aSourceMap._mappings.toArray().slice() | ||
.sort(util.compareByOriginalPositions); | ||
@@ -110,0 +109,0 @@ |
@@ -15,2 +15,3 @@ /* -*- Mode: js; js-indent-level: 2; -*- */ | ||
var ArraySet = require('./array-set').ArraySet; | ||
var MappingList = require('./mapping-list').MappingList; | ||
@@ -31,5 +32,6 @@ /** | ||
this._sourceRoot = util.getArg(aArgs, 'sourceRoot', null); | ||
this._skipValidation = util.getArg(aArgs, 'skipValidation', false); | ||
this._sources = new ArraySet(); | ||
this._names = new ArraySet(); | ||
this._mappings = []; | ||
this._mappings = new MappingList(); | ||
this._sourcesContents = null; | ||
@@ -104,3 +106,5 @@ } | ||
this._validateMapping(generated, original, source, name); | ||
if (!this._skipValidation) { | ||
this._validateMapping(generated, original, source, name); | ||
} | ||
@@ -115,3 +119,3 @@ if (source != null && !this._sources.has(source)) { | ||
this._mappings.push({ | ||
this._mappings.add({ | ||
generatedLine: generated.line, | ||
@@ -193,3 +197,3 @@ generatedColumn: generated.column, | ||
// Find mappings for the "sourceFile" | ||
this._mappings.forEach(function (mapping) { | ||
this._mappings.unsortedForEach(function (mapping) { | ||
if (mapping.source === sourceFile && mapping.originalLine != null) { | ||
@@ -300,11 +304,6 @@ // Check if it can be mapped by the source map, then update the mapping. | ||
// The mappings must be guaranteed to be in sorted order before we start | ||
// serializing them or else the generated line numbers (which are defined | ||
// via the ';' separators) will be all messed up. Note: it might be more | ||
// performant to maintain the sorting as we insert them, rather than as we | ||
// serialize them, but the big O is the same either way. | ||
this._mappings.sort(util.compareByGeneratedPositions); | ||
var mappings = this._mappings.toArray(); | ||
for (var i = 0, len = this._mappings.length; i < len; i++) { | ||
mapping = this._mappings[i]; | ||
for (var i = 0, len = mappings.length; i < len; i++) { | ||
mapping = mappings[i]; | ||
@@ -320,3 +319,3 @@ if (mapping.generatedLine !== previousGeneratedLine) { | ||
if (i > 0) { | ||
if (!util.compareByGeneratedPositions(mapping, this._mappings[i - 1])) { | ||
if (!util.compareByGeneratedPositions(mapping, mappings[i - 1])) { | ||
continue; | ||
@@ -323,0 +322,0 @@ } |
@@ -19,4 +19,4 @@ /* -*- Mode: js; js-indent-level: 2; -*- */ | ||
// Matches a Windows-style newline, or any character. | ||
var REGEX_CHARACTER = /\r\n|[\s\S]/g; | ||
// Newline character code for charCodeAt() comparisons | ||
var NEWLINE_CODE = 10; | ||
@@ -379,8 +379,8 @@ // Private symbol for identifying `SourceNode`s when multiple versions of | ||
} | ||
chunk.match(REGEX_CHARACTER).forEach(function (ch, idx, array) { | ||
if (REGEX_NEWLINE.test(ch)) { | ||
for (var idx = 0, length = chunk.length; idx < length; idx++) { | ||
if (chunk.charCodeAt(idx) === NEWLINE_CODE) { | ||
generated.line++; | ||
generated.column = 0; | ||
// Mappings end at eol | ||
if (idx + 1 === array.length) { | ||
if (idx + 1 === length) { | ||
lastOriginalSource = null; | ||
@@ -403,5 +403,5 @@ sourceMappingActive = false; | ||
} else { | ||
generated.column += ch.length; | ||
generated.column++; | ||
} | ||
}); | ||
} | ||
}); | ||
@@ -408,0 +408,0 @@ this.walkSourceContents(function (sourceFile, sourceContent) { |
{ | ||
"name": "source-map", | ||
"description": "Generates and consumes source maps", | ||
"version": "0.1.42", | ||
"version": "0.1.43", | ||
"homepage": "https://github.com/mozilla/source-map", | ||
@@ -34,3 +34,5 @@ "author": "Nick Fitzgerald <nfitzgerald@mozilla.com>", | ||
"J. Ryan Stinnett <jryans@gmail.com>", | ||
"Jack Herrington <jherrington@walmartlabs.com>" | ||
"Jack Herrington <jherrington@walmartlabs.com>", | ||
"Chris Truter <jeffpalentine@gmail.com>", | ||
"Daniel Espeset <daniel@danielespeset.com>" | ||
], | ||
@@ -37,0 +39,0 @@ "repository": { |
@@ -277,2 +277,7 @@ # Source Map | ||
* `skipValidation`: Optional. When `true`, disables validation of mappings as | ||
they are added. This can improve performance but should be used with | ||
discretion, as a last resort. Even then, one should avoid using this flag when | ||
running tests, if possible. | ||
#### SourceMapGenerator.fromSourceMap(sourceMapConsumer) | ||
@@ -279,0 +284,0 @@ |
@@ -101,2 +101,23 @@ /* -*- Mode: js; js-indent-level: 2; -*- */ | ||
exports['test adding mappings with skipValidation'] = function (assert, util) { | ||
var map = new SourceMapGenerator({ | ||
file: 'generated-foo.js', | ||
sourceRoot: '.', | ||
skipValidation: true | ||
}); | ||
// Not enough info, caught by `util.getArgs` | ||
assert.throws(function () { | ||
map.addMapping({}); | ||
}); | ||
// Original file position, but no source. Not checked. | ||
assert.doesNotThrow(function () { | ||
map.addMapping({ | ||
generated: { line: 1, column: 1 }, | ||
original: { line: 1, column: 1 } | ||
}); | ||
}); | ||
}; | ||
exports['test that the correct mappings are being generated'] = function (assert, util) { | ||
@@ -103,0 +124,0 @@ var map = new SourceMapGenerator({ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
200678
38
4730
476