core: Made PropertyMap::entry take &str instead of String. We often don't need ownership here.

This commit is contained in:
Nathan Adams 2020-07-04 01:17:45 +02:00 committed by Mike Welsh
parent b5c06be8a2
commit f4921fad45
2 changed files with 6 additions and 11 deletions

View File

@ -159,12 +159,7 @@ impl<'gc> ScriptObject<'gc> {
native_value: Option<Value<'gc>>,
is_enumerable: bool,
) {
match self
.0
.write(gc_context)
.values
.entry(name.to_string(), false)
{
match self.0.write(gc_context).values.entry(name, false) {
Entry::Occupied(mut entry) => {
if let Property::Stored { value, .. } = entry.get_mut() {
match native_value {
@ -267,7 +262,7 @@ impl<'gc> ScriptObject<'gc> {
.0
.write(context.gc_context)
.values
.entry(name.to_owned(), activation.is_case_sensitive())
.entry(name, activation.is_case_sensitive())
{
Entry::Occupied(mut entry) => entry.get_mut().set(value.clone()),
Entry::Vacant(entry) => {

View File

@ -26,7 +26,7 @@ impl<V> PropertyMap<V> {
}
}
pub fn entry(&mut self, key: String, case_sensitive: bool) -> Entry<V> {
pub fn entry(&mut self, key: &str, case_sensitive: bool) -> Entry<V> {
if case_sensitive {
match self.0.get_full_mut(&CaseSensitiveStr(&key)) {
Some((index, _, _)) => Entry::Occupied(OccupiedEntry {
@ -35,7 +35,7 @@ impl<V> PropertyMap<V> {
}),
None => Entry::Vacant(VacantEntry {
map: &mut self.0,
key,
key: key.to_string(),
}),
}
} else {
@ -46,7 +46,7 @@ impl<V> PropertyMap<V> {
}),
None => Entry::Vacant(VacantEntry {
map: &mut self.0,
key,
key: key.to_string(),
}),
}
}
@ -77,7 +77,7 @@ impl<V> PropertyMap<V> {
}
pub fn insert(&mut self, key: String, value: V, case_sensitive: bool) -> Option<V> {
match self.entry(key, case_sensitive) {
match self.entry(&key, case_sensitive) {
Entry::Occupied(entry) => Some(entry.insert(value)),
Entry::Vacant(entry) => {
entry.insert(value);