mirror of
https://github.com/servo/servo.git
synced 2025-09-30 00:29:14 +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
|
@ -7,9 +7,9 @@ use std::iter::FromIterator;
|
|||
use std::ptr::NonNull;
|
||||
|
||||
use canvas_traits::webgl::{GlType, TexFormat, WebGLSLVersion, WebGLVersion};
|
||||
use fnv::{FnvHashMap, FnvHashSet};
|
||||
use js::jsapi::JSObject;
|
||||
use malloc_size_of::MallocSizeOf;
|
||||
use rustc_hash::{FxHashMap, FxHashSet};
|
||||
type GLenum = u32;
|
||||
|
||||
use super::wrapper::{TypedWebGLExtensionWrapper, WebGLExtensionWrapper};
|
||||
|
@ -81,25 +81,25 @@ const DEFAULT_DISABLED_GET_VERTEX_ATTRIB_NAMES_WEBGL1: [GLenum; 1] =
|
|||
/// WebGL features that are enabled/disabled by WebGL Extensions.
|
||||
#[derive(JSTraceable, MallocSizeOf)]
|
||||
struct WebGLExtensionFeatures {
|
||||
gl_extensions: FnvHashSet<String>,
|
||||
disabled_tex_types: FnvHashSet<GLenum>,
|
||||
not_filterable_tex_types: FnvHashSet<GLenum>,
|
||||
gl_extensions: FxHashSet<String>,
|
||||
disabled_tex_types: FxHashSet<GLenum>,
|
||||
not_filterable_tex_types: FxHashSet<GLenum>,
|
||||
#[no_trace]
|
||||
effective_tex_internal_formats: FnvHashMap<TexFormatType, TexFormat>,
|
||||
effective_tex_internal_formats: FxHashMap<TexFormatType, TexFormat>,
|
||||
/// WebGL Hint() targets enabled by extensions.
|
||||
hint_targets: FnvHashSet<GLenum>,
|
||||
hint_targets: FxHashSet<GLenum>,
|
||||
/// WebGL GetParameter() names enabled by extensions.
|
||||
disabled_get_parameter_names: FnvHashSet<GLenum>,
|
||||
disabled_get_parameter_names: FxHashSet<GLenum>,
|
||||
/// WebGL GetTexParameter() names enabled by extensions.
|
||||
disabled_get_tex_parameter_names: FnvHashSet<GLenum>,
|
||||
disabled_get_tex_parameter_names: FxHashSet<GLenum>,
|
||||
/// WebGL GetAttribVertex() names enabled by extensions.
|
||||
disabled_get_vertex_attrib_names: FnvHashSet<GLenum>,
|
||||
disabled_get_vertex_attrib_names: FxHashSet<GLenum>,
|
||||
/// WebGL OES_element_index_uint extension.
|
||||
element_index_uint_enabled: bool,
|
||||
/// WebGL EXT_blend_minmax extension.
|
||||
blend_minmax_enabled: bool,
|
||||
/// WebGL supported texture compression formats enabled by extensions.
|
||||
tex_compression_formats: FnvHashMap<GLenum, TexCompression>,
|
||||
tex_compression_formats: FxHashMap<GLenum, TexCompression>,
|
||||
}
|
||||
|
||||
impl WebGLExtensionFeatures {
|
||||
|
@ -199,7 +199,7 @@ impl WebGLExtensions {
|
|||
if self.extensions.borrow().is_empty() {
|
||||
let gl_str = cb();
|
||||
self.features.borrow_mut().gl_extensions =
|
||||
FnvHashSet::from_iter(gl_str.split(&[',', ' '][..]).map(|s| s.into()));
|
||||
FxHashSet::from_iter(gl_str.split(&[',', ' '][..]).map(|s| s.into()));
|
||||
self.register_all_extensions();
|
||||
}
|
||||
}
|
||||
|
@ -382,7 +382,7 @@ impl WebGLExtensions {
|
|||
}
|
||||
|
||||
pub(crate) fn add_tex_compression_formats(&self, formats: &[TexCompression]) {
|
||||
let formats: FnvHashMap<GLenum, TexCompression> = formats
|
||||
let formats: FxHashMap<GLenum, TexCompression> = formats
|
||||
.iter()
|
||||
.map(|&compression| (compression.format.as_gl_constant(), compression))
|
||||
.collect();
|
||||
|
|
|
@ -4,13 +4,13 @@
|
|||
|
||||
// https://www.khronos.org/registry/webgl/specs/latest/1.0/webgl.idl
|
||||
use std::cell::Cell;
|
||||
use std::collections::HashSet;
|
||||
|
||||
use canvas_traits::webgl::{
|
||||
ActiveAttribInfo, ActiveUniformBlockInfo, ActiveUniformInfo, WebGLCommand, WebGLError,
|
||||
WebGLProgramId, WebGLResult, webgl_channel,
|
||||
};
|
||||
use dom_struct::dom_struct;
|
||||
use fnv::FnvHashSet;
|
||||
|
||||
use crate::canvas_context::CanvasContext;
|
||||
use crate::dom::bindings::cell::{DomRefCell, Ref};
|
||||
|
@ -180,8 +180,8 @@ impl WebGLProgram {
|
|||
let link_info = receiver.recv().unwrap();
|
||||
|
||||
{
|
||||
let mut used_locs = FnvHashSet::default();
|
||||
let mut used_names = FnvHashSet::default();
|
||||
let mut used_locs = HashSet::new();
|
||||
let mut used_names = HashSet::new();
|
||||
for active_attrib in &*link_info.active_attribs {
|
||||
let Some(location) = active_attrib.location else {
|
||||
continue;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue