@@ -67,7 +67,7 @@ Object.defineProperty(SourceMapConsumer.prototype, '_generatedMappings', {
67
67
enumerable : true ,
68
68
get : function ( ) {
69
69
if ( ! this . __generatedMappings ) {
70
- this . _parseMappings ( this . _mappings , this . sourceRoot ) ;
70
+ this . _sortGeneratedMappings ( ) ;
71
71
}
72
72
73
73
return this . __generatedMappings ;
@@ -80,13 +80,39 @@ Object.defineProperty(SourceMapConsumer.prototype, '_originalMappings', {
80
80
enumerable : true ,
81
81
get : function ( ) {
82
82
if ( ! this . __originalMappings ) {
83
- this . _parseMappings ( this . _mappings , this . sourceRoot ) ;
83
+ this . _sortOriginalMappings ( ) ;
84
84
}
85
85
86
86
return this . __originalMappings ;
87
87
}
88
88
} ) ;
89
89
90
+ SourceMapConsumer . prototype . __generatedMappingsUnsorted = null ;
91
+ Object . defineProperty ( SourceMapConsumer . prototype , '_generatedMappingsUnsorted' , {
92
+ configurable : true ,
93
+ enumerable : true ,
94
+ get : function ( ) {
95
+ if ( ! this . __generatedMappingsUnsorted ) {
96
+ this . _parseMappings ( this . _mappings , this . sourceRoot ) ;
97
+ }
98
+
99
+ return this . __generatedMappingsUnsorted ;
100
+ }
101
+ } ) ;
102
+
103
+ SourceMapConsumer . prototype . __originalMappingsUnsorted = null ;
104
+ Object . defineProperty ( SourceMapConsumer . prototype , '_originalMappingsUnsorted' , {
105
+ configurable : true ,
106
+ enumerable : true ,
107
+ get : function ( ) {
108
+ if ( ! this . __originalMappingsUnsorted ) {
109
+ this . _parseMappings ( this . _mappings , this . sourceRoot ) ;
110
+ }
111
+
112
+ return this . __originalMappingsUnsorted ;
113
+ }
114
+ } ) ;
115
+
90
116
SourceMapConsumer . prototype . _charIsMappingSeparator =
91
117
function SourceMapConsumer_charIsMappingSeparator ( aStr , index ) {
92
118
var c = aStr . charAt ( index ) ;
@@ -103,6 +129,20 @@ SourceMapConsumer.prototype._parseMappings =
103
129
throw new Error ( "Subclasses must implement _parseMappings" ) ;
104
130
} ;
105
131
132
+ SourceMapConsumer . prototype . _sortGeneratedMappings =
133
+ function SourceMapConsumer_sortGeneratedMappings ( ) {
134
+ const mappings = this . _generatedMappingsUnsorted ;
135
+ quickSort ( mappings , util . compareByGeneratedPositionsDeflated ) ;
136
+ this . __generatedMappings = mappings ;
137
+ } ;
138
+
139
+ SourceMapConsumer . prototype . _sortOriginalMappings =
140
+ function SourceMapConsumer_sortOriginalMappings ( ) {
141
+ const mappings = this . _originalMappingsUnsorted ;
142
+ quickSort ( mappings , util . compareByOriginalPositions ) ;
143
+ this . __originalMappings = mappings ;
144
+ } ;
145
+
106
146
SourceMapConsumer . GENERATED_ORDER = 1 ;
107
147
SourceMapConsumer . ORIGINAL_ORDER = 2 ;
108
148
@@ -564,11 +604,9 @@ BasicSourceMapConsumer.prototype._parseMappings =
564
604
}
565
605
}
566
606
567
- quickSort ( generatedMappings , util . compareByGeneratedPositionsDeflated ) ;
568
- this . __generatedMappings = generatedMappings ;
607
+ this . __generatedMappingsUnsorted = generatedMappings ;
569
608
570
- quickSort ( originalMappings , util . compareByOriginalPositions ) ;
571
- this . __originalMappings = originalMappings ;
609
+ this . __originalMappingsUnsorted = originalMappings ;
572
610
} ;
573
611
574
612
/**
@@ -1097,8 +1135,8 @@ IndexedSourceMapConsumer.prototype.generatedPositionFor =
1097
1135
*/
1098
1136
IndexedSourceMapConsumer . prototype . _parseMappings =
1099
1137
function IndexedSourceMapConsumer_parseMappings ( aStr , aSourceRoot ) {
1100
- this . __generatedMappings = [ ] ;
1101
- this . __originalMappings = [ ] ;
1138
+ const generatedMappings = this . __generatedMappingsUnsorted = [ ] ;
1139
+ const originalMappings = this . __originalMappingsUnsorted = [ ] ;
1102
1140
for ( var i = 0 ; i < this . _sections . length ; i ++ ) {
1103
1141
var section = this . _sections [ i ] ;
1104
1142
var sectionMappings = section . consumer . _generatedMappings ;
@@ -1134,15 +1172,12 @@ IndexedSourceMapConsumer.prototype._parseMappings =
1134
1172
name : name
1135
1173
} ;
1136
1174
1137
- this . __generatedMappings . push ( adjustedMapping ) ;
1175
+ generatedMappings . push ( adjustedMapping ) ;
1138
1176
if ( typeof adjustedMapping . originalLine === 'number' ) {
1139
- this . __originalMappings . push ( adjustedMapping ) ;
1177
+ originalMappings . push ( adjustedMapping ) ;
1140
1178
}
1141
1179
}
1142
1180
}
1143
-
1144
- quickSort ( this . __generatedMappings , util . compareByGeneratedPositionsDeflated ) ;
1145
- quickSort ( this . __originalMappings , util . compareByOriginalPositions ) ;
1146
1181
} ;
1147
1182
1148
1183
exports . IndexedSourceMapConsumer = IndexedSourceMapConsumer ;
0 commit comments