Skip to content

Commit

Permalink
Made symbol_properties contain a RcSymbol instead of just hash
Browse files Browse the repository at this point in the history
  • Loading branch information
HalidOdat committed Aug 5, 2020
1 parent e4065ba commit 30f5102
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 20 deletions.
35 changes: 18 additions & 17 deletions boa/src/builtins/object/internal_methods.rs
Original file line number Diff line number Diff line change
Expand Up @@ -279,21 +279,22 @@ impl Object {
d
})
}
PropertyKey::Symbol(ref symbol) => self
.symbol_properties()
.get(&symbol.hash())
.map_or_else(Property::empty, |v| {
let mut d = Property::empty();
if v.is_data_descriptor() {
d.value = v.value.clone();
} else {
debug_assert!(v.is_accessor_descriptor());
d.get = v.get.clone();
d.set = v.set.clone();
}
d.attribute = v.attribute;
d
}),
PropertyKey::Symbol(ref symbol) => {
self.symbol_properties()
.get(symbol)
.map_or_else(Property::empty, |v| {
let mut d = Property::empty();
if v.is_data_descriptor() {
d.value = v.value.clone();
} else {
debug_assert!(v.is_accessor_descriptor());
d.get = v.get.clone();
d.set = v.set.clone();
}
d.attribute = v.attribute;
d
})
}
PropertyKey::Index(index) => {
self.indexed_properties
.get(&index)
Expand Down Expand Up @@ -375,7 +376,7 @@ impl Object {
PropertyKey::Index(index) => self.indexed_properties.insert(index, property),
PropertyKey::String(ref string) => self.properties.insert(string.clone(), property),
PropertyKey::Symbol(ref symbol) => {
self.symbol_properties.insert(symbol.hash(), property)
self.symbol_properties.insert(symbol.clone(), property)
}
}
}
Expand All @@ -386,7 +387,7 @@ impl Object {
match key {
PropertyKey::Index(index) => self.indexed_properties.remove(&index),
PropertyKey::String(ref string) => self.properties.remove(string),
PropertyKey::Symbol(ref symbol) => self.symbol_properties.remove(&symbol.hash()),
PropertyKey::Symbol(ref symbol) => self.symbol_properties.remove(symbol),
}
}

Expand Down
6 changes: 3 additions & 3 deletions boa/src/builtins/object/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ pub struct Object {
/// Properties
properties: FxHashMap<RcString, Property>,
/// Symbol Properties
symbol_properties: FxHashMap<u32, Property>,
symbol_properties: FxHashMap<RcSymbol, Property>,
/// Instance prototype `__proto__`.
prototype: Value,
/// Some rust object that stores internal state
Expand Down Expand Up @@ -415,12 +415,12 @@ impl Object {
}

#[inline]
pub fn symbol_properties(&self) -> &FxHashMap<u32, Property> {
pub fn symbol_properties(&self) -> &FxHashMap<RcSymbol, Property> {
&self.symbol_properties
}

#[inline]
pub fn symbol_properties_mut(&mut self) -> &mut FxHashMap<u32, Property> {
pub fn symbol_properties_mut(&mut self) -> &mut FxHashMap<RcSymbol, Property> {
&mut self.symbol_properties
}

Expand Down

0 comments on commit 30f5102

Please sign in to comment.