@@ -109,6 +109,7 @@ pub struct SourceMapGenerator {
109109 ignore_list : Vec < u32 > ,
110110 debug_id : Option < String > ,
111111 scopes : Option < ScopeInfo > ,
112+ has_range_mappings : bool ,
112113 assume_sorted : bool ,
113114 // Tracks whether `mappings` is non-decreasing by (generated_line,
114115 // generated_column), maintained incrementally on every push so the encode
@@ -133,6 +134,7 @@ impl SourceMapGenerator {
133134 ignore_list : Vec :: new ( ) ,
134135 debug_id : None ,
135136 scopes : None ,
137+ has_range_mappings : false ,
136138 assume_sorted : false ,
137139 mappings_in_order : true ,
138140 source_map : FxHashMap :: default ( ) ,
@@ -155,6 +157,7 @@ impl SourceMapGenerator {
155157 ignore_list : Vec :: new ( ) ,
156158 debug_id : None ,
157159 scopes : None ,
160+ has_range_mappings : false ,
158161 assume_sorted : false ,
159162 mappings_in_order : true ,
160163 source_map : FxHashMap :: default ( ) ,
@@ -236,6 +239,9 @@ impl SourceMapGenerator {
236239 /// `(generated_line, generated_column)` ordering exactly.
237240 #[ inline]
238241 fn push_mapping ( & mut self , mapping : Mapping ) {
242+ if mapping. is_range_mapping {
243+ self . has_range_mappings = true ;
244+ }
239245 if self . mappings_in_order
240246 && let Some ( last) = self . mappings . last ( )
241247 && ( mapping. generated_line , mapping. generated_column )
@@ -592,7 +598,7 @@ impl SourceMapGenerator {
592598 /// Encode range mappings to a VLQ string.
593599 /// Returns `None` if no range mappings exist.
594600 fn encode_range_mappings ( & self ) -> Option < String > {
595- if !self . mappings . iter ( ) . any ( |m| m . is_range_mapping ) {
601+ if !self . has_range_mappings {
596602 return None ;
597603 }
598604
0 commit comments