From 859c756faee05ca2b4b98877c644bb8181ca8aeb Mon Sep 17 00:00:00 2001 From: Nicolas Silva Date: Wed, 20 Feb 2019 10:01:28 +0100 Subject: [PATCH] Bug 1476368 - Pre-allocate primitives vector in setup_picture_caching. r=gw --HG-- extra : source : 32aa85626f6c484dff616ec9ae78ca53ea38dec5 extra : histedit_source : 109a92a512932d686f31906c37392f5f55db18e8 --- gfx/wr/webrender/src/display_list_flattener.rs | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/gfx/wr/webrender/src/display_list_flattener.rs b/gfx/wr/webrender/src/display_list_flattener.rs index 183fdaa721f6..ac3b0fa37584 100644 --- a/gfx/wr/webrender/src/display_list_flattener.rs +++ b/gfx/wr/webrender/src/display_list_flattener.rs @@ -312,10 +312,7 @@ impl<'a> DisplayListFlattener<'a> { }; // Get the list of existing primitives in the main stacking context. - let mut old_prim_list = mem::replace( - primitives, - Vec::new(), - ); + let mut old_prim_list = primitives.take(); // In the simple case, there are no preceding or trailing primitives, // because everything is anchored to the root scroll node. Handle @@ -409,6 +406,7 @@ impl<'a> DisplayListFlattener<'a> { // This contains the tile caching picture, with preceding and // trailing primitives outside the main scroll root. + primitives.reserve(preceding_prims.len() + trailing_prims.len() + 1); primitives.extend(preceding_prims); primitives.push(instance); primitives.extend(trailing_prims);