File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -252,6 +252,16 @@ impl Stream for CachedSourceStream<'_> {
252252 }
253253 }
254254
255+ fn sections_len ( & self ) -> usize {
256+ if let Some ( index_map) = self . cache . columns_index_map . get ( ) {
257+ index_map. as_ref ( ) . map ( |index_map| index_map. sections ( ) . len ( ) ) . unwrap_or ( 0 )
258+ } else if let Some ( index_map) = self . cache . line_only_index_map . get ( ) {
259+ index_map. as_ref ( ) . map ( |index_map| index_map. sections ( ) . len ( ) ) . unwrap_or ( 0 )
260+ } else {
261+ self . stream . sections_len ( )
262+ }
263+ }
264+
255265 fn sections < ' a > (
256266 & ' a self ,
257267 object_pool : & ' a ObjectPool ,
@@ -304,6 +314,7 @@ impl Stream for CachedSourceStream<'_> {
304314}
305315
306316impl ToStream for CachedSource {
317+ #[ inline]
307318 fn to_stream < ' a > ( & ' a self ) -> Box < dyn Stream + ' a > {
308319 Box :: new ( CachedSourceStream :: new ( self ) )
309320 }
Original file line number Diff line number Diff line change @@ -220,8 +220,9 @@ impl Source for ConcatSource {
220220 object_pool : & ObjectPool ,
221221 options : & MapOptions ,
222222 ) -> Option < IndexSourceMap > {
223- let mut sections = Vec :: new ( ) ;
224- self . to_stream ( ) . sections (
223+ let stream = self . to_stream ( ) ;
224+ let mut sections = Vec :: with_capacity ( stream. sections_len ( ) ) ;
225+ stream. sections (
225226 object_pool,
226227 options. columns ,
227228 & mut |offset, map| {
@@ -451,6 +452,10 @@ impl Stream for ConcatSourceStream<'_> {
451452 }
452453 }
453454
455+ fn sections_len ( & self ) -> usize {
456+ self . children_streams . iter ( ) . map ( |child_stream| child_stream. sections_len ( ) ) . sum ( )
457+ }
458+
454459 fn sections < ' a > (
455460 & ' a self ,
456461 object_pool : & ' a ObjectPool ,
@@ -481,6 +486,7 @@ impl Stream for ConcatSourceStream<'_> {
481486}
482487
483488impl ToStream for ConcatSource {
489+ #[ inline]
484490 fn to_stream < ' a > ( & ' a self ) -> Box < dyn Stream + ' a > {
485491 Box :: new ( ConcatSourceStream :: new ( self ) )
486492 }
Original file line number Diff line number Diff line change @@ -90,6 +90,8 @@ pub trait Stream {
9090 on_name : crate :: helpers:: OnName < ' _ , ' a > ,
9191 ) -> crate :: helpers:: GeneratedInfo ;
9292
93+ fn sections_len ( & self ) -> usize ;
94+
9395 fn sections < ' a > (
9496 & ' a self ,
9597 object_pool : & ' a ObjectPool ,
Original file line number Diff line number Diff line change @@ -248,6 +248,10 @@ impl Stream for OriginalSourceStream<'_> {
248248 }
249249 }
250250
251+ fn sections_len ( & self ) -> usize {
252+ 1
253+ }
254+
251255 fn sections < ' a > (
252256 & ' a self ,
253257 object_pool : & ' a ObjectPool ,
@@ -268,6 +272,7 @@ impl Stream for OriginalSourceStream<'_> {
268272}
269273
270274impl ToStream for OriginalSource {
275+ #[ inline]
271276 fn to_stream < ' a > ( & ' a self ) -> Box < dyn Stream + ' a > {
272277 Box :: new ( OriginalSourceStream :: new ( self ) )
273278 }
Original file line number Diff line number Diff line change @@ -131,6 +131,10 @@ impl Stream for RawStringStream<'_> {
131131 }
132132 }
133133
134+ fn sections_len ( & self ) -> usize {
135+ 0
136+ }
137+
134138 fn sections < ' a > (
135139 & ' a self ,
136140 _object_pool : & ' a ObjectPool ,
@@ -144,6 +148,7 @@ impl Stream for RawStringStream<'_> {
144148}
145149
146150impl ToStream for RawStringSource {
151+ #[ inline]
147152 fn to_stream < ' a > ( & ' a self ) -> Box < dyn Stream + ' a > {
148153 Box :: new ( RawStringStream :: new ( self ) )
149154 }
@@ -283,6 +288,10 @@ impl Stream for RawBufferSourceStream<'_> {
283288 }
284289 }
285290
291+ fn sections_len ( & self ) -> usize {
292+ 0
293+ }
294+
286295 fn sections < ' a > (
287296 & ' a self ,
288297 _object_pool : & ' a ObjectPool ,
@@ -297,6 +306,7 @@ impl Stream for RawBufferSourceStream<'_> {
297306}
298307
299308impl ToStream for RawBufferSource {
309+ #[ inline]
300310 fn to_stream < ' a > ( & ' a self ) -> Box < dyn Stream + ' a > {
301311 Box :: new ( RawBufferSourceStream ( self ) )
302312 }
Original file line number Diff line number Diff line change @@ -861,6 +861,10 @@ impl Stream for ReplaceSourceStream<'_> {
861861 }
862862 }
863863
864+ fn sections_len ( & self ) -> usize {
865+ 0
866+ }
867+
864868 fn sections < ' a > (
865869 & ' a self ,
866870 object_pool : & ' a ObjectPool ,
@@ -881,6 +885,7 @@ impl Stream for ReplaceSourceStream<'_> {
881885}
882886
883887impl ToStream for ReplaceSource {
888+ #[ inline]
884889 fn to_stream < ' a > ( & ' a self ) -> Box < dyn Stream + ' a > {
885890 Box :: new ( ReplaceSourceStream :: new ( self ) )
886891 }
Original file line number Diff line number Diff line change @@ -206,6 +206,7 @@ impl Source for BoxSource {
206206dyn_clone:: clone_trait_object!( Source ) ;
207207
208208impl ToStream for BoxSource {
209+ #[ inline]
209210 fn to_stream < ' a > ( & ' a self ) -> Box < dyn Stream + ' a > {
210211 self . as_ref ( ) . to_stream ( )
211212 }
Original file line number Diff line number Diff line change @@ -226,6 +226,10 @@ impl Stream for SourceMapSourceStream<'_> {
226226 }
227227 }
228228
229+ fn sections_len ( & self ) -> usize {
230+ 1
231+ }
232+
229233 fn sections < ' a > (
230234 & ' a self ,
231235 object_pool : & ' a ObjectPool ,
Original file line number Diff line number Diff line change @@ -72,6 +72,10 @@ impl Stream for CompatSourceStream<'_> {
7272 )
7373 }
7474
75+ fn sections_len ( & self ) -> usize {
76+ 1
77+ }
78+
7579 fn sections < ' a > (
7680 & ' a self ,
7781 _object_pool : & ' a ObjectPool ,
@@ -85,6 +89,7 @@ impl Stream for CompatSourceStream<'_> {
8589}
8690
8791impl ToStream for CompatSource {
92+ #[ inline]
8893 fn to_stream < ' a > ( & ' a self ) -> Box < dyn Stream + ' a > {
8994 Box :: new ( CompatSourceStream :: new ( self ) )
9095 }
You can’t perform that action at this time.
0 commit comments