forge
Explore
Log in

Don't you dare go Hollow

layout: Do not recompute total_weight every iteration

Browse files at this commit

dfc2d452c55d59d6d9014c98a9da3a082c4f7379Ivan MolodetskikhParent: 66f23c3
src/layout/workspace.rsmodified+12 -11
@@ -3074,6 +3074,17 @@ impl<W: LayoutElement> Column<W> {
3074 }3074 }
3075 }3075 }
3076 3076
3077+ let mut total_weight: f64 = heights
3078+ .iter()
3079+ .filter_map(|h| {
3080+ if let WindowHeight::Auto { weight } = *h {
3081+ Some(weight)
3082+ } else {
3083+ None
3084+ }
3085+ })
3086+ .sum();
3087+
3077 // Iteratively try to distribute the remaining height, checking against tile min heights.3088 // Iteratively try to distribute the remaining height, checking against tile min heights.
3078 // Pick an auto height according to the current sizes, then check if it satisfies all3089 // Pick an auto height according to the current sizes, then check if it satisfies all
3079 // remaining min heights. If not, allocate fixed height to those tiles and repeat the3090 // remaining min heights. If not, allocate fixed height to those tiles and repeat the
@@ -3086,17 +3097,6 @@ impl<W: LayoutElement> Column<W> {
3086 // However, most max height uses are for fixed-size dialogs, where min height == max_height.3097 // However, most max height uses are for fixed-size dialogs, where min height == max_height.
3087 // This case is separately handled above.3098 // This case is separately handled above.
3088 while auto_tiles_left > 0 {3099 while auto_tiles_left > 0 {
3089- let mut total_weight: f64 = heights
3090- .iter()
3091- .filter_map(|h| {
3092- if let WindowHeight::Auto { weight } = *h {
3093- Some(weight)
3094- } else {
3095- None
3096- }
3097- })
3098- .sum();
3099-
3100 // Wayland requires us to round the requested size for a window to integer logical3100 // Wayland requires us to round the requested size for a window to integer logical
3101 // pixels, therefore we compute the remaining auto height dynamically.3101 // pixels, therefore we compute the remaining auto height dynamically.
3102 let mut height_left_2 = height_left;3102 let mut height_left_2 = height_left;
@@ -3120,6 +3120,7 @@ impl<W: LayoutElement> Column<W> {
3120 auto = min_size.h;3120 auto = min_size.h;
3121 *h = WindowHeight::Fixed(auto);3121 *h = WindowHeight::Fixed(auto);
3122 height_left -= auto;3122 height_left -= auto;
3123+ total_weight -= weight;
3123 auto_tiles_left -= 1;3124 auto_tiles_left -= 1;
3124 unsatisfied_min = true;3125 unsatisfied_min = true;
3125 }3126 }