Bug 1476368 - Reserve storage for the dynamic property vectors in the bindings before filling them. r=kvark
authorNicolas Silva <nsilva@mozilla.com>
Tue, 19 Feb 2019 18:43:41 +0100
changeset 518592 659354cec17d666e115e76e64ba2d4c93a259dab
parent 518591 d0c93c9acd660e67bcbcd9d64921b7815452d25c
child 518593 9af23e1d86c8b70beeea117eb3c68d02e7966ae2
push id10862
push userffxbld-merge
push dateMon, 11 Mar 2019 13:01:11 +0000
treeherdermozilla-beta@a2e7f5c935da [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerskvark
bugs1476368
milestone67.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1476368 - Reserve storage for the dynamic property vectors in the bindings before filling them. r=kvark
gfx/webrender_bindings/src/bindings.rs
--- a/gfx/webrender_bindings/src/bindings.rs
+++ b/gfx/webrender_bindings/src/bindings.rs
@@ -1394,29 +1394,31 @@ pub extern "C" fn wr_transaction_update_
     let mut properties = DynamicProperties {
         transforms: Vec::new(),
         floats: Vec::new(),
     };
 
     if transform_count > 0 {
         let transform_slice = make_slice(transform_array, transform_count);
 
+        properties.transforms.reserve(transform_slice.len());
         for element in transform_slice.iter() {
             let prop = PropertyValue {
                 key: PropertyBindingKey::new(element.id),
                 value: element.transform.into(),
             };
 
             properties.transforms.push(prop);
         }
     }
 
     if opacity_count > 0 {
         let opacity_slice = make_slice(opacity_array, opacity_count);
 
+        properties.floats.reserve(opacity_slice.len());
         for element in opacity_slice.iter() {
             let prop = PropertyValue {
                 key: PropertyBindingKey::new(element.id),
                 value: element.opacity,
             };
             properties.floats.push(prop);
         }
     }
@@ -1435,17 +1437,17 @@ pub extern "C" fn wr_transaction_append_
     }
 
     let mut properties = DynamicProperties {
         transforms: Vec::new(),
         floats: Vec::new(),
     };
 
     let transform_slice = make_slice(transform_array, transform_count);
-
+    properties.transforms.reserve(transform_slice.len());
     for element in transform_slice.iter() {
         let prop = PropertyValue {
             key: PropertyBindingKey::new(element.id),
             value: element.transform.into(),
         };
 
         properties.transforms.push(prop);
     }