Removed FnvHash and transformed the rest to FxHashmap (#39233)

This should be the final PR for the Hash Function series that is
trivial.

Of note: I decided to transform `HashMapTracedValues<Atom,..>` to use
FxBuildHasher. This is likely not going to improve performance as Atom's
already have a unique u32 that is used as the Hash but it safes a few
bytes for the RandomState that is normally in the HashMap.

Signed-off-by: Narfinger <Narfinger@users.noreply.github.com>

Testing: Hash function changes should not change functionality, we
slightly decrease the size and unit tests still work.

Signed-off-by: Narfinger <Narfinger@users.noreply.github.com>
This commit is contained in:
Narfinger 2025-09-10 15:34:54 +02:00 committed by GitHub
parent 726b456120
commit 84465e7768
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
55 changed files with 211 additions and 202 deletions

View file

@ -3,7 +3,6 @@
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
use std::cell::RefCell;
use std::collections::HashMap;
use std::collections::hash_map::{Entry, Keys};
use std::rc::Rc;
@ -20,9 +19,9 @@ use embedder_traits::{
TouchEvent, TouchEventResult, TouchEventType, TouchId, ViewportDetails,
};
use euclid::{Point2D, Scale, Vector2D};
use fnv::FnvHashSet;
use log::{debug, warn};
use malloc_size_of::MallocSizeOf;
use rustc_hash::{FxHashMap, FxHashSet};
use servo_geometry::DeviceIndependentPixel;
use style_traits::{CSSPixel, PinchZoomFactor};
use webrender_api::units::{DeviceIntPoint, DevicePixel, DevicePoint, DeviceRect, LayoutVector2D};
@ -80,7 +79,7 @@ pub(crate) struct WebViewRenderer {
/// The rectangle of the [`WebView`] in device pixels, which is the viewport.
pub rect: DeviceRect,
/// Tracks details about each active pipeline that the compositor knows about.
pub pipelines: HashMap<PipelineId, PipelineDetails>,
pub pipelines: FxHashMap<PipelineId, PipelineDetails>,
/// Data that is shared by all WebView renderers.
pub(crate) global: Rc<RefCell<ServoRenderer>>,
/// Pending scroll/zoom events.
@ -228,7 +227,7 @@ impl WebViewRenderer {
// state for some unattached pipelines in order to preserve scroll position when
// navigating backward and forward.
fn collect_pipelines(
pipelines: &mut FnvHashSet<PipelineId>,
pipelines: &mut FxHashSet<PipelineId>,
frame_tree: &SendableFrameTree,
) {
pipelines.insert(frame_tree.pipeline.id);
@ -237,7 +236,7 @@ impl WebViewRenderer {
}
}
let mut attached_pipelines: FnvHashSet<PipelineId> = FnvHashSet::default();
let mut attached_pipelines: FxHashSet<PipelineId> = FxHashSet::default();
collect_pipelines(&mut attached_pipelines, frame_tree);
self.pipelines