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
|
@ -28,9 +28,9 @@ compositing_traits = { workspace = true }
|
|||
constellation_traits = { workspace = true }
|
||||
crossbeam-channel = { workspace = true }
|
||||
dpi = { workspace = true }
|
||||
rustc-hash = { workspace = true }
|
||||
embedder_traits = { workspace = true }
|
||||
euclid = { workspace = true }
|
||||
fnv = { workspace = true }
|
||||
gleam = { workspace = true }
|
||||
ipc-channel = { workspace = true }
|
||||
libc = { workspace = true }
|
||||
|
|
|
@ -3,8 +3,8 @@
|
|||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||
|
||||
use std::cell::{Cell, Ref, RefCell};
|
||||
use std::collections::HashMap;
|
||||
use std::collections::hash_map::Entry;
|
||||
use std::collections::{HashMap, HashSet};
|
||||
use std::env;
|
||||
use std::fs::create_dir_all;
|
||||
use std::iter::once;
|
||||
|
@ -28,7 +28,6 @@ use crossbeam_channel::Sender;
|
|||
use dpi::PhysicalSize;
|
||||
use embedder_traits::{CompositorHitTestResult, InputEvent, ShutdownState, ViewportDetails};
|
||||
use euclid::{Point2D, Rect, Scale, Size2D, Transform3D};
|
||||
use fnv::FnvHashMap;
|
||||
use ipc_channel::ipc::{self, IpcSharedMemory};
|
||||
use log::{debug, info, trace, warn};
|
||||
use pixels::{CorsStatus, ImageFrame, ImageMetadata, PixelFormat, RasterImage};
|
||||
|
@ -37,6 +36,7 @@ use profile_traits::mem::{
|
|||
};
|
||||
use profile_traits::time::{self as profile_time, ProfilerCategory};
|
||||
use profile_traits::{path, time_profile};
|
||||
use rustc_hash::{FxHashMap, FxHashSet};
|
||||
use servo_config::{opts, pref};
|
||||
use servo_geometry::DeviceIndependentPixel;
|
||||
use style_traits::CSSPixel;
|
||||
|
@ -1184,7 +1184,7 @@ impl IOCompositor {
|
|||
// complete (i.e. has *all* layers painted to the requested epoch).
|
||||
// This gets sent to the constellation for comparison with the current
|
||||
// frame tree.
|
||||
let mut pipeline_epochs = FnvHashMap::default();
|
||||
let mut pipeline_epochs = FxHashMap::default();
|
||||
for id in self
|
||||
.webview_renderers
|
||||
.iter()
|
||||
|
@ -1702,7 +1702,7 @@ struct FrameDelayer {
|
|||
pending_frame: bool,
|
||||
/// A list of pipelines that should be notified when we are no longer waiting for
|
||||
/// canvas images.
|
||||
waiting_pipelines: HashSet<PipelineId>,
|
||||
waiting_pipelines: FxHashSet<PipelineId>,
|
||||
}
|
||||
|
||||
impl FrameDelayer {
|
||||
|
|
|
@ -2,11 +2,10 @@
|
|||
* 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 embedder_traits::{TouchId, TouchSequenceId};
|
||||
use euclid::{Point2D, Scale, Vector2D};
|
||||
use log::{debug, error, warn};
|
||||
use rustc_hash::FxHashMap;
|
||||
use webrender_api::units::{DeviceIntPoint, DevicePixel, DevicePoint, LayoutVector2D};
|
||||
|
||||
use self::TouchSequenceState::*;
|
||||
|
@ -26,7 +25,7 @@ const FLING_MAX_SCREEN_PX: f32 = 4000.0;
|
|||
pub struct TouchHandler {
|
||||
pub current_sequence_id: TouchSequenceId,
|
||||
// todo: VecDeque + modulo arithmetic would be more efficient.
|
||||
touch_sequence_map: HashMap<TouchSequenceId, TouchSequenceInfo>,
|
||||
touch_sequence_map: FxHashMap<TouchSequenceId, TouchSequenceInfo>,
|
||||
}
|
||||
|
||||
/// Whether the default move action is allowed or not.
|
||||
|
@ -203,12 +202,14 @@ impl TouchHandler {
|
|||
prevent_move: TouchMoveAllowed::Pending,
|
||||
pending_touch_move_action: None,
|
||||
};
|
||||
// We insert a simulated initial touch sequence, which is already finished,
|
||||
// so that we always have one element in the map, which simplifies creating
|
||||
// a new touch sequence on touch_down.
|
||||
let mut touch_sequence_map = FxHashMap::default();
|
||||
touch_sequence_map.insert(TouchSequenceId::new(), finished_info);
|
||||
TouchHandler {
|
||||
current_sequence_id: TouchSequenceId::new(),
|
||||
// We insert a simulated initial touch sequence, which is already finished,
|
||||
// so that we always have one element in the map, which simplifies creating
|
||||
// a new touch sequence on touch_down.
|
||||
touch_sequence_map: HashMap::from([(TouchSequenceId::new(), finished_info)]),
|
||||
touch_sequence_map,
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -2,10 +2,10 @@
|
|||
* 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::collections::hash_map::{Entry, Values, ValuesMut};
|
||||
|
||||
use base::id::WebViewId;
|
||||
use rustc_hash::FxHashMap;
|
||||
|
||||
use crate::webview_renderer::{UnknownWebView, WebViewRenderer};
|
||||
|
||||
|
@ -13,7 +13,7 @@ use crate::webview_renderer::{UnknownWebView, WebViewRenderer};
|
|||
pub struct WebViewManager<WebView> {
|
||||
/// Our top-level browsing contexts. In the WebRender scene, their pipelines are the children of
|
||||
/// a single root pipeline that also applies any pinch zoom transformation.
|
||||
webviews: HashMap<WebViewId, WebView>,
|
||||
webviews: FxHashMap<WebViewId, WebView>,
|
||||
|
||||
/// The order to paint them in, topmost last.
|
||||
pub(crate) painting_order: Vec<WebViewId>,
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue