Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sync changes from mozilla-central #3813

Merged
merged 8 commits into from Dec 13, 2019

Bug 1602458 - Prevent recycled hash maps from growing indefinitely. r=gw

  • Loading branch information
nical authored and moz-gfx committed Dec 12, 2019
commit b461b9e9beb42dcdae43e468f27d8b822423f2c1
@@ -1680,16 +1680,34 @@ impl TileCacheInstance {
self.current_tile_size = prev_state.current_tile_size;

fn recycle_map<K: std::cmp::Eq + std::hash::Hash, V>(
ideal_len: usize,
dest: &mut FastHashMap<K, V>,
src: FastHashMap<K, V>,
) {
if dest.capacity() < src.capacity() {
*dest = src;
if src.capacity() < 3 * ideal_len {
*dest = src;
} else {
dest.clear();
dest.reserve(ideal_len);
}
}
}
recycle_map(&mut self.old_tiles, prev_state.allocations.old_tiles);
recycle_map(&mut self.old_opacity_bindings, prev_state.allocations.old_opacity_bindings);
recycle_map(&mut self.compare_cache, prev_state.allocations.compare_cache);
recycle_map(
self.tiles.len(),
&mut self.old_tiles,
prev_state.allocations.old_tiles,
);
recycle_map(
self.opacity_bindings.len(),
&mut self.old_opacity_bindings,
prev_state.allocations.old_opacity_bindings,
);
recycle_map(
prev_state.allocations.compare_cache.len(),
&mut self.compare_cache,
prev_state.allocations.compare_cache,
);
}

// Only evaluate what tile size to use fairly infrequently, so that we don't end
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.