File tree Expand file tree Collapse file tree 2 files changed +13
-10
lines changed
Expand file tree Collapse file tree 2 files changed +13
-10
lines changed Original file line number Diff line number Diff line change @@ -142,16 +142,9 @@ impl LogViewerApp {
142142
143143 if let Some ( data) = & mut self . data {
144144 table. body ( |body| {
145- // TODO 4: Figure out if calculating these values only once is worth it.
146- // TODO 4: Remove hard coded "msg"
147- let heights: Vec < f32 > = data
148- . rows_iter ( )
149- . map ( |x| {
150- ( 1f32 ) . max ( x. field_value ( "msg" ) . display ( ) . lines ( ) . count ( ) as f32 )
151- * text_height
152- } )
153- . collect ( ) ;
154- body. heterogeneous_rows ( heights. into_iter ( ) , |mut row| {
145+ let heights = data. row_heights ( text_height) ;
146+
147+ body. heterogeneous_rows ( heights, |mut row| {
155148 let row_index = row. index ( ) ;
156149 let log_row = & data
157150 . rows_iter ( )
Original file line number Diff line number Diff line change @@ -311,6 +311,16 @@ impl Data {
311311 "No"
312312 } )
313313 }
314+
315+ pub ( crate ) fn row_heights ( & self , text_height : f32 ) -> impl Iterator < Item = f32 > {
316+ self . rows_iter ( )
317+ . map ( |x| {
318+ // TODO 4: Remove hard coded "msg"
319+ ( 1f32 ) . max ( x. field_value ( "msg" ) . display ( ) . lines ( ) . count ( ) as f32 ) * text_height
320+ } )
321+ . collect :: < Vec < f32 > > ( )
322+ . into_iter ( )
323+ }
314324}
315325
316326/// If the slice of fields and values matches the filter then the indices of the fields that match are returned or None if it does not match
You can’t perform that action at this time.
0 commit comments