tawasuyu

tawasuyu/taffy

A high performance rust-powered UI layout library

HTML 5544Rust 88Markdown 11TOML 91926 Definitions

Don't use vec![] macro (fixes alloc build)

7726226c5fca1421c16001d80e2dfbfeb0beb6c8 · by Nico Burns · (3 years ago) · parent 7d6d4cda1 · browse the tree at this commit

Semantic delta · 1

src/compute/flexbox.rs

1 files · +6 −2

diff --git a/src/compute/flexbox.rs b/src/compute/flexbox.rs
index 6a2669a63..308002a1f 100644
--- a/src/compute/flexbox.rs
+++ b/src/compute/flexbox.rs
@@ -735,13 +735,17 @@ fn collect_flex_lines<'a>(
     flex_items: &'a mut Vec<FlexItem>,
 ) -> Vec<FlexLine<'a>> {
     if tree.style(node).flex_wrap == FlexWrap::NoWrap {
-        vec![FlexLine { items: flex_items.as_mut_slice(), cross_size: 0.0, offset_cross: 0.0 }]
+        let mut lines = Vec::with_capacity(1);
+        lines.push(FlexLine { items: flex_items.as_mut_slice(), cross_size: 0.0, offset_cross: 0.0 });
+        lines
     } else {
         match available_space.main(constants.dir) {
             // If we're sizing under a max-content constraint then the flex items will never wrap
             // (at least for now - future extensions to the CSS spec may add provisions for forced wrap points)
             AvailableSpace::MaxContent => {
-                vec![FlexLine { items: flex_items.as_mut_slice(), cross_size: 0.0, offset_cross: 0.0 }]
+                let mut lines = Vec::with_capacity(1);
+                lines.push(FlexLine { items: flex_items.as_mut_slice(), cross_size: 0.0, offset_cross: 0.0 });
+                lines
             }
             // If flex-wrap is Wrap and we're sizing under a min-content constraint, then we take every possible wrapping opportunity
             // and place each item in it's own line