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

@ -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,
}
}