From 80b62b8fcd0ebde2d68a8bf23bddd906afa8331b Mon Sep 17 00:00:00 2001 From: Nicolas Silva Date: Wed, 24 Jun 2020 12:49:13 +0000 Subject: [PATCH] Bug 1642629 - Preallocate gpu cache texture vectors. r=gw Differential Revision: https://phabricator.services.mozilla.com/D80437 --- gfx/wr/webrender/src/gpu_cache.rs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/gfx/wr/webrender/src/gpu_cache.rs b/gfx/wr/webrender/src/gpu_cache.rs index 14acf5ece2bb..a7bf2964ec74 100644 --- a/gfx/wr/webrender/src/gpu_cache.rs +++ b/gfx/wr/webrender/src/gpu_cache.rs @@ -34,7 +34,8 @@ use crate::profiler::GpuCacheProfileCounters; use crate::render_backend::{FrameStamp, FrameId}; use crate::prim_store::VECS_PER_SEGMENT; use crate::renderer::MAX_VERTEX_TEXTURE_WIDTH; -use std::{mem, u16, u32}; +use crate::util::VecHelper; +use std::{u16, u32}; use std::num::NonZeroU32; use std::ops::Add; use std::time::{Duration, Instant}; @@ -901,9 +902,9 @@ impl GpuCache { frame_id: self.now.frame_id(), clear, height: self.texture.height, - debug_commands: mem::replace(&mut self.texture.debug_commands, Vec::new()), - updates: mem::replace(&mut self.texture.updates, Vec::new()), - blocks: mem::replace(&mut self.texture.pending_blocks, Vec::new()), + debug_commands: self.texture.debug_commands.take_and_preallocate(), + updates: self.texture.updates.take_and_preallocate(), + blocks: self.texture.pending_blocks.take_and_preallocate(), } }