diff --git a/rbx_binary/src/serializer/state.rs b/rbx_binary/src/serializer/state.rs index ac5b70a9..168ee818 100644 --- a/rbx_binary/src/serializer/state.rs +++ b/rbx_binary/src/serializer/state.rs @@ -1,11 +1,11 @@ use std::{ borrow::{Borrow, Cow}, - collections::{btree_map, BTreeMap, BTreeSet}, + collections::{btree_map, BTreeMap}, convert::TryInto, io::Write, }; -use ahash::{HashMap, HashMapExt, HashSet, HashSetExt}; +use ahash::{HashMap, HashMapExt, HashSetExt}; use rbx_dom_weak::{ types::{ Attributes, Axes, BinaryString, BrickColor, CFrame, Color3, Color3uint8, ColorSequence, @@ -14,7 +14,7 @@ use rbx_dom_weak::{ SecurityCapabilities, SharedString, Tags, UDim, UDim2, UniqueId, Variant, VariantType, Vector2, Vector3, Vector3int16, }, - Instance, Ustr, WeakDom, + Instance, Ustr, UstrSet, WeakDom, }; use rbx_reflection::{ @@ -99,7 +99,7 @@ struct TypeInfo<'dom, 'db> { /// A set containing the properties that we have seen so far in the file and /// processed. This helps us avoid traversing the reflection database /// multiple times if there are many copies of the same kind of instance. - properties_visited: HashSet<(Ustr, VariantType)>, + properties_visited: UstrSet, } /// A property on a specific class that our serializer knows about. @@ -129,7 +129,7 @@ struct PropInfo<'db> { /// allocate) in most cases. However, if an instance is missing a property /// from its canonical name, but does have another variant, we can use this /// set to recover and map those values. - aliases: BTreeSet, + aliases: UstrSet, /// The default value for this property that should be used if any instances /// are missing this property. @@ -206,7 +206,7 @@ impl<'dom, 'db> TypeInfos<'dom, 'db> { PropInfo { prop_type: Type::String, serialized_name: "Name".into(), - aliases: BTreeSet::new(), + aliases: UstrSet::new(), default_value: Cow::Owned(Variant::String(String::new())), migration: None, }, @@ -218,7 +218,7 @@ impl<'dom, 'db> TypeInfos<'dom, 'db> { instances: Vec::new(), properties, class_descriptor, - properties_visited: HashSet::new(), + properties_visited: UstrSet::new(), }); } @@ -330,19 +330,14 @@ impl<'dom, 'db, W: Write> SerializerState<'dom, 'db, W> { } } - // Skip this property+value type pair if we've already seen it. - if type_info - .properties_visited - .contains(&(*prop_name, prop_value.ty())) - { + // Skip this property if we've already seen it. + if type_info.properties_visited.contains(prop_name) { continue; } // ...but add it to the set of visited properties if we haven't seen // it. - type_info - .properties_visited - .insert((*prop_name, prop_value.ty())); + type_info.properties_visited.insert(*prop_name); let canonical_name; let serialized_name; @@ -462,7 +457,7 @@ impl<'dom, 'db, W: Write> SerializerState<'dom, 'db, W> { PropInfo { prop_type: ser_type, serialized_name, - aliases: BTreeSet::new(), + aliases: UstrSet::new(), default_value, migration, },