@@ -12,7 +12,7 @@ use crate::{
1212 linear_map:: LinearMap ,
1313 object_pool:: ObjectPool ,
1414 source:: { Mapping , OriginalLocation } ,
15- BoxSource , MapOptions , RawStringSource , Rope , Source , SourceExt , SourceMap ,
15+ BoxSource , MapOptions , RawStringSource , Source , SourceExt , SourceMap ,
1616 SourceValue ,
1717} ;
1818
@@ -169,31 +169,19 @@ impl Source for ConcatSource {
169169 }
170170
171171 let mut string = String :: with_capacity ( self . size ( ) ) ;
172- for child in children {
173- match child. rope ( ) {
174- Rope :: Light ( s) => string. push_str ( s) ,
175- Rope :: Full ( chunks) => {
176- for chunk in chunks {
177- string. push_str ( chunk) ;
178- }
179- }
180- }
181- }
172+ children. iter ( ) . for_each ( |child| {
173+ child. rope ( & mut |chunk| {
174+ string. push_str ( chunk) ;
175+ } ) ;
176+ } ) ;
182177 SourceValue :: String ( Cow :: Owned ( string) )
183178 }
184179
185- fn rope ( & self ) -> Rope {
180+ fn rope < ' a > ( & ' a self , on_chunk : & mut dyn FnMut ( & ' a str ) ) {
186181 let children = self . optimized_children ( ) ;
187- if children. len ( ) == 1 {
188- children[ 0 ] . rope ( )
189- } else {
190- Rope :: Full ( Box :: new ( children. iter ( ) . flat_map (
191- |child| match child. rope ( ) {
192- Rope :: Light ( s) => Box :: new ( std:: iter:: once ( s) ) ,
193- Rope :: Full ( iter) => iter,
194- } ,
195- ) ) )
196- }
182+ children. iter ( ) . for_each ( |child| {
183+ child. rope ( on_chunk) ;
184+ } ) ;
197185 }
198186
199187 fn buffer ( & self ) -> Cow < [ u8 ] > {
0 commit comments