avm2: Use FNV hashing for all other parts of the VM.
This commit is contained in:
parent
3329e2a965
commit
92697c9f1e
|
@ -7,8 +7,8 @@ use crate::avm2::script::{Script, TranslationUnit};
|
|||
use crate::context::UpdateContext;
|
||||
use crate::string::AvmString;
|
||||
use crate::tag_utils::SwfSlice;
|
||||
use fnv::FnvHashMap;
|
||||
use gc_arena::{Collect, MutationContext};
|
||||
use std::collections::HashMap;
|
||||
use std::rc::Rc;
|
||||
use swf::avm2::read::Reader;
|
||||
|
||||
|
@ -86,7 +86,7 @@ pub struct Avm2<'gc> {
|
|||
///
|
||||
/// TODO: These should be weak object pointers, but our current garbage
|
||||
/// collector does not support weak references.
|
||||
broadcast_list: HashMap<AvmString<'gc>, Vec<Object<'gc>>>,
|
||||
broadcast_list: FnvHashMap<AvmString<'gc>, Vec<Object<'gc>>>,
|
||||
|
||||
#[cfg(feature = "avm_debug")]
|
||||
pub debug_output: bool,
|
||||
|
@ -102,7 +102,7 @@ impl<'gc> Avm2<'gc> {
|
|||
globals,
|
||||
system_prototypes: None,
|
||||
system_classes: None,
|
||||
broadcast_list: HashMap::new(),
|
||||
broadcast_list: Default::default(),
|
||||
|
||||
#[cfg(feature = "avm_debug")]
|
||||
debug_output: false,
|
||||
|
|
|
@ -6,8 +6,8 @@ use crate::avm2::object::{ByteArrayObject, TObject};
|
|||
use crate::avm2::script::Script;
|
||||
use crate::avm2::value::Value;
|
||||
use crate::avm2::Error;
|
||||
use fnv::FnvHashMap;
|
||||
use gc_arena::{Collect, GcCell, MutationContext};
|
||||
use std::collections::HashMap;
|
||||
|
||||
/// Represents a set of scripts and movies that share traits across different
|
||||
/// script-global scopes.
|
||||
|
@ -19,7 +19,7 @@ pub struct Domain<'gc>(GcCell<'gc, DomainData<'gc>>);
|
|||
#[collect(no_drop)]
|
||||
struct DomainData<'gc> {
|
||||
/// A list of all exported definitions and the script that exported them.
|
||||
defs: HashMap<QName<'gc>, Script<'gc>>,
|
||||
defs: FnvHashMap<QName<'gc>, Script<'gc>>,
|
||||
|
||||
/// The parent domain.
|
||||
parent: Option<Domain<'gc>>,
|
||||
|
@ -46,7 +46,7 @@ impl<'gc> Domain<'gc> {
|
|||
Self(GcCell::allocate(
|
||||
mc,
|
||||
DomainData {
|
||||
defs: HashMap::new(),
|
||||
defs: Default::default(),
|
||||
parent: None,
|
||||
domain_memory: None,
|
||||
},
|
||||
|
@ -64,7 +64,7 @@ impl<'gc> Domain<'gc> {
|
|||
let this = Self(GcCell::allocate(
|
||||
activation.context.gc_context,
|
||||
DomainData {
|
||||
defs: HashMap::new(),
|
||||
defs: Default::default(),
|
||||
parent: Some(parent),
|
||||
domain_memory: None,
|
||||
},
|
||||
|
|
|
@ -7,8 +7,9 @@ use crate::avm2::value::Value;
|
|||
use crate::avm2::Error;
|
||||
use crate::display_object::TDisplayObject;
|
||||
use crate::string::AvmString;
|
||||
use fnv::FnvHashMap;
|
||||
use gc_arena::Collect;
|
||||
use std::collections::{BTreeMap, HashMap};
|
||||
use std::collections::BTreeMap;
|
||||
use std::hash::{Hash, Hasher};
|
||||
|
||||
/// Which phase of event dispatch is currently occurring.
|
||||
|
@ -174,12 +175,12 @@ impl<'gc> Event<'gc> {
|
|||
/// A set of handlers organized by event type, priority, and order added.
|
||||
#[derive(Clone, Collect, Debug)]
|
||||
#[collect(no_drop)]
|
||||
pub struct DispatchList<'gc>(HashMap<AvmString<'gc>, BTreeMap<i32, Vec<EventHandler<'gc>>>>);
|
||||
pub struct DispatchList<'gc>(FnvHashMap<AvmString<'gc>, BTreeMap<i32, Vec<EventHandler<'gc>>>>);
|
||||
|
||||
impl<'gc> DispatchList<'gc> {
|
||||
/// Construct a new dispatch list.
|
||||
pub fn new() -> Self {
|
||||
Self(HashMap::new())
|
||||
Self(Default::default())
|
||||
}
|
||||
|
||||
/// Get all of the event handlers for a given event type, if such a type
|
||||
|
|
|
@ -14,9 +14,9 @@ use crate::avm2::traits::{Trait, TraitKind};
|
|||
use crate::avm2::value::Value;
|
||||
use crate::avm2::Error;
|
||||
use crate::string::AvmString;
|
||||
use fnv::FnvHashMap;
|
||||
use gc_arena::{Collect, GcCell, MutationContext};
|
||||
use std::cell::{Ref, RefMut};
|
||||
use std::collections::HashMap;
|
||||
use std::hash::{Hash, Hasher};
|
||||
|
||||
/// An Object which can be called to execute its function code.
|
||||
|
@ -70,7 +70,7 @@ pub struct ClassObjectData<'gc> {
|
|||
/// as `None` here. AVM2 considers both applications to be separate
|
||||
/// classes, though we consider the parameter to be the class `Object` when
|
||||
/// we get a param of `null`.
|
||||
applications: HashMap<Option<ClassObject<'gc>>, ClassObject<'gc>>,
|
||||
applications: FnvHashMap<Option<ClassObject<'gc>>, ClassObject<'gc>>,
|
||||
|
||||
/// Interfaces implemented by this class.
|
||||
interfaces: Vec<ClassObject<'gc>>,
|
||||
|
@ -199,7 +199,7 @@ impl<'gc> ClassObject<'gc> {
|
|||
constructor: class.read().instance_init(),
|
||||
native_constructor: class.read().native_instance_init(),
|
||||
params: None,
|
||||
applications: HashMap::new(),
|
||||
applications: Default::default(),
|
||||
interfaces: Vec::new(),
|
||||
resolved_instance_traits: PropertyMap::new(),
|
||||
resolved_class_traits: PropertyMap::new(),
|
||||
|
@ -1294,7 +1294,7 @@ impl<'gc> TObject<'gc> for ClassObject<'gc> {
|
|||
constructor,
|
||||
native_constructor,
|
||||
params: Some(object_param),
|
||||
applications: HashMap::new(),
|
||||
applications: Default::default(),
|
||||
interfaces: Vec::new(),
|
||||
resolved_instance_traits: PropertyMap::new(),
|
||||
resolved_class_traits: PropertyMap::new(),
|
||||
|
|
|
@ -5,9 +5,9 @@ use crate::avm2::object::script_object::ScriptObjectData;
|
|||
use crate::avm2::object::{ClassObject, Object, ObjectPtr, TObject};
|
||||
use crate::avm2::value::Value;
|
||||
use crate::avm2::Error;
|
||||
use fnv::FnvHashMap;
|
||||
use gc_arena::{Collect, GcCell, MutationContext};
|
||||
use std::cell::{Ref, RefMut};
|
||||
use std::collections::HashMap;
|
||||
|
||||
/// A class instance allocator that allocates Dictionary objects.
|
||||
pub fn dictionary_allocator<'gc>(
|
||||
|
@ -21,7 +21,7 @@ pub fn dictionary_allocator<'gc>(
|
|||
activation.context.gc_context,
|
||||
DictionaryObjectData {
|
||||
base,
|
||||
object_space: HashMap::new(),
|
||||
object_space: Default::default(),
|
||||
},
|
||||
))
|
||||
.into())
|
||||
|
@ -43,7 +43,7 @@ pub struct DictionaryObjectData<'gc> {
|
|||
base: ScriptObjectData<'gc>,
|
||||
|
||||
/// Object key storage
|
||||
object_space: HashMap<Object<'gc>, Value<'gc>>,
|
||||
object_space: FnvHashMap<Object<'gc>, Value<'gc>>,
|
||||
}
|
||||
|
||||
impl<'gc> DictionaryObject<'gc> {
|
||||
|
@ -101,7 +101,7 @@ impl<'gc> TObject<'gc> for DictionaryObject<'gc> {
|
|||
activation.context.gc_context,
|
||||
DictionaryObjectData {
|
||||
base,
|
||||
object_space: HashMap::new(),
|
||||
object_space: Default::default(),
|
||||
},
|
||||
))
|
||||
.into())
|
||||
|
|
Loading…
Reference in New Issue