mirror of
https://github.com/servo/servo.git
synced 2025-09-27 15:20:09 +01:00
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:
parent
726b456120
commit
84465e7768
55 changed files with 211 additions and 202 deletions
|
@ -26,7 +26,6 @@ cssparser = { workspace = true }
|
|||
data-url = { workspace = true }
|
||||
embedder_traits = { workspace = true }
|
||||
euclid = { workspace = true }
|
||||
fnv = { workspace = true }
|
||||
fonts = { path = "../fonts" }
|
||||
fonts_traits = { workspace = true }
|
||||
fxhash = { workspace = true }
|
||||
|
|
|
@ -2,11 +2,11 @@
|
|||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||
|
||||
use std::collections::HashMap;
|
||||
use std::sync::Arc;
|
||||
|
||||
use embedder_traits::UntrustedNodeAddress;
|
||||
use euclid::Size2D;
|
||||
use fnv::FnvHashMap;
|
||||
use fonts::FontContext;
|
||||
use layout_api::wrapper_traits::ThreadSafeLayoutNode;
|
||||
use layout_api::{
|
||||
|
@ -102,8 +102,7 @@ pub(crate) struct ImageResolver {
|
|||
|
||||
// A cache that maps image resources used in CSS (e.g as the `url()` value
|
||||
// for `background-image` or `content` property) to the final resolved image data.
|
||||
pub resolved_images_cache:
|
||||
Arc<RwLock<FnvHashMap<(ServoUrl, UsePlaceholder), CachedImageOrError>>>,
|
||||
pub resolved_images_cache: Arc<RwLock<HashMap<(ServoUrl, UsePlaceholder), CachedImageOrError>>>,
|
||||
|
||||
/// The current animation timeline value used to properly initialize animating images.
|
||||
pub animation_timeline_value: f64,
|
||||
|
|
|
@ -2,14 +2,13 @@
|
|||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||
|
||||
use std::collections::HashMap;
|
||||
|
||||
use app_units::Au;
|
||||
use base::id::ScrollTreeNodeId;
|
||||
use embedder_traits::Cursor;
|
||||
use euclid::{Box2D, Vector2D};
|
||||
use kurbo::{Ellipse, Shape};
|
||||
use layout_api::{ElementsFromPointFlags, ElementsFromPointResult};
|
||||
use rustc_hash::FxHashMap;
|
||||
use servo_geometry::FastLayoutTransform;
|
||||
use style::computed_values::backface_visibility::T as BackfaceVisibility;
|
||||
use style::computed_values::pointer_events::T as PointerEvents;
|
||||
|
@ -40,7 +39,7 @@ pub(crate) struct HitTest<'a> {
|
|||
/// The resulting [`HitTestResultItems`] for this hit test.
|
||||
results: Vec<ElementsFromPointResult>,
|
||||
/// A cache of hit test results for shared clip nodes.
|
||||
clip_hit_test_results: HashMap<ClipId, bool>,
|
||||
clip_hit_test_results: FxHashMap<ClipId, bool>,
|
||||
}
|
||||
|
||||
impl<'a> HitTest<'a> {
|
||||
|
@ -55,7 +54,7 @@ impl<'a> HitTest<'a> {
|
|||
projected_point_to_test: None,
|
||||
stacking_context_tree,
|
||||
results: Vec::new(),
|
||||
clip_hit_test_results: HashMap::new(),
|
||||
clip_hit_test_results: FxHashMap::default(),
|
||||
};
|
||||
stacking_context_tree
|
||||
.root_stacking_context
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
#![allow(unsafe_code)]
|
||||
|
||||
use std::cell::{Cell, RefCell};
|
||||
use std::collections::HashMap;
|
||||
use std::fmt::Debug;
|
||||
use std::process;
|
||||
use std::rc::Rc;
|
||||
|
@ -21,10 +22,8 @@ use cssparser::ParserInput;
|
|||
use embedder_traits::{Theme, ViewportDetails};
|
||||
use euclid::default::{Point2D as UntypedPoint2D, Rect as UntypedRect};
|
||||
use euclid::{Point2D, Scale, Size2D};
|
||||
use fnv::FnvHashMap;
|
||||
use fonts::{FontContext, FontContextWebFontMethods};
|
||||
use fonts_traits::StylesheetWebFontLoadFinishedCallback;
|
||||
use fxhash::FxHashMap;
|
||||
use layout_api::wrapper_traits::LayoutNode;
|
||||
use layout_api::{
|
||||
BoxAreaType, IFrameSizes, Layout, LayoutConfig, LayoutDamage, LayoutFactory,
|
||||
|
@ -41,6 +40,7 @@ use profile_traits::time::{
|
|||
self as profile_time, TimerMetadata, TimerMetadataFrameType, TimerMetadataReflowType,
|
||||
};
|
||||
use profile_traits::{path, time_profile};
|
||||
use rustc_hash::FxHashMap;
|
||||
use script::layout_dom::{ServoLayoutDocument, ServoLayoutElement, ServoLayoutNode};
|
||||
use script_traits::{DrawAPaintImageResult, PaintWorkletError, Painter, ScriptThreadMessage};
|
||||
use servo_arc::Arc as ServoArc;
|
||||
|
@ -181,7 +181,7 @@ pub struct LayoutThread {
|
|||
// A cache that maps image resources specified in CSS (e.g as the `url()` value
|
||||
// for `background-image` or `content` properties) to either the final resolved
|
||||
// image data, or an error if the image cache failed to load/decode the image.
|
||||
resolved_images_cache: Arc<RwLock<FnvHashMap<(ServoUrl, UsePlaceholder), CachedImageOrError>>>,
|
||||
resolved_images_cache: Arc<RwLock<HashMap<(ServoUrl, UsePlaceholder), CachedImageOrError>>>,
|
||||
|
||||
/// The executors for paint worklets.
|
||||
registered_painters: RegisteredPaintersImpl,
|
||||
|
@ -514,7 +514,7 @@ impl Layout for LayoutThread {
|
|||
|
||||
fn set_scroll_offsets_from_renderer(
|
||||
&mut self,
|
||||
scroll_states: &FnvHashMap<ExternalScrollId, LayoutVector2D>,
|
||||
scroll_states: &FxHashMap<ExternalScrollId, LayoutVector2D>,
|
||||
) {
|
||||
let mut stacking_context_tree = self.stacking_context_tree.borrow_mut();
|
||||
let Some(stacking_context_tree) = stacking_context_tree.as_mut() else {
|
||||
|
@ -1422,7 +1422,7 @@ struct RegisteredPainterImpl {
|
|||
painter: Box<dyn Painter>,
|
||||
name: Atom,
|
||||
// FIXME: Should be a PrecomputedHashMap.
|
||||
properties: FxHashMap<Atom, PropertyId>,
|
||||
properties: fxhash::FxHashMap<Atom, PropertyId>,
|
||||
}
|
||||
|
||||
impl SpeculativePainter for RegisteredPainterImpl {
|
||||
|
@ -1437,7 +1437,7 @@ impl SpeculativePainter for RegisteredPainterImpl {
|
|||
}
|
||||
|
||||
impl RegisteredSpeculativePainter for RegisteredPainterImpl {
|
||||
fn properties(&self) -> &FxHashMap<Atom, PropertyId> {
|
||||
fn properties(&self) -> &fxhash::FxHashMap<Atom, PropertyId> {
|
||||
&self.properties
|
||||
}
|
||||
fn name(&self) -> Atom {
|
||||
|
@ -1458,7 +1458,7 @@ impl Painter for RegisteredPainterImpl {
|
|||
}
|
||||
}
|
||||
|
||||
struct RegisteredPaintersImpl(FnvHashMap<Atom, RegisteredPainterImpl>);
|
||||
struct RegisteredPaintersImpl(HashMap<Atom, RegisteredPainterImpl>);
|
||||
|
||||
impl RegisteredSpeculativePainters for RegisteredPaintersImpl {
|
||||
fn get(&self, name: &Atom) -> Option<&dyn RegisteredSpeculativePainter> {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue