Skip to content

Commit

Permalink
Move class name into TypeInfos::get_or_create instead of borrowing
Browse files Browse the repository at this point in the history
  • Loading branch information
kennethloeffler committed Oct 29, 2024
1 parent 9727368 commit 1c3e18a
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions rbx_binary/src/serializer/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -177,8 +177,8 @@ impl<'dom, 'db> TypeInfos<'dom, 'db> {

/// Finds the type info from the given ClassName if it exists, or creates
/// one and returns a reference to it if not.
fn get_or_create(&mut self, class: &Ustr) -> &mut TypeInfo<'dom, 'db> {
if !self.values.contains_key(class) {
fn get_or_create(&mut self, class: Ustr) -> &mut TypeInfo<'dom, 'db> {
if !self.values.contains_key(&class) {
let type_id = self.next_type_id;
self.next_type_id += 1;

Expand Down Expand Up @@ -212,7 +212,7 @@ impl<'dom, 'db> TypeInfos<'dom, 'db> {
);

self.values.insert(
*class,
class,
TypeInfo {
type_id,
is_service,
Expand All @@ -226,7 +226,7 @@ impl<'dom, 'db> TypeInfos<'dom, 'db> {

// This unwrap will not panic because we always insert this key into
// type_infos in this function.
self.values.get_mut(class).unwrap()
self.values.get_mut(&class).unwrap()
}
}

Expand Down Expand Up @@ -318,7 +318,7 @@ impl<'dom, 'db, W: Write> SerializerState<'dom, 'db, W> {
#[allow(clippy::map_entry)]
#[profiling::function]
pub fn collect_type_info(&mut self, instance: &'dom Instance) -> Result<(), InnerError> {
let type_info = self.type_infos.get_or_create(&instance.class);
let type_info = self.type_infos.get_or_create(instance.class);
type_info.instances.push(instance);

for (prop_name, prop_value) in &instance.properties {
Expand Down

0 comments on commit 1c3e18a

Please sign in to comment.