mirror of
https://github.com/rojo-rbx/rojo.git
synced 2026-10-22 21:41:37 +00:00
Refactor font comparison logic in variant_eq and hash_variant functions
- Simplified the comparison logic for `Font` variants in the `variant_eq` and `variant_eq_disk` functions by consolidating multiple conditions into single lines for improved readability. - Removed the handling of `cached_face_id` from the `hash_variant` function, streamlining the hashing process for `Font` variants. These changes aim to enhance code clarity and maintainability while preserving the existing functionality.
This commit is contained in:
parent
d9fa62c88e
commit
b85c5f5ec7
3 changed files with 3 additions and 15 deletions
2
rbx-dom
2
rbx-dom
|
|
@ -1 +1 @@
|
|||
Subproject commit a98c70c8752071b59b852d2f7e55376b1bbd2370
|
||||
Subproject commit 47b61af5aa94f6b26aac64ad94edd4b5d1b8e6ba
|
||||
|
|
@ -96,12 +96,6 @@ pub fn hash_variant(hasher: &mut Hasher, value: &Variant) {
|
|||
n_hash!(hasher, f.weight as u16);
|
||||
n_hash!(hasher, f.style as u8);
|
||||
hash!(hasher, f.family.as_bytes());
|
||||
if let Some(cache) = &f.cached_face_id {
|
||||
hash!(hasher, &[0x01]);
|
||||
hash!(hasher, cache.as_bytes());
|
||||
} else {
|
||||
hash!(hasher, &[0x00]);
|
||||
}
|
||||
}
|
||||
Variant::Int32(n) => n_hash!(hasher, n),
|
||||
Variant::Int64(n) => n_hash!(hasher, n),
|
||||
|
|
|
|||
|
|
@ -102,10 +102,7 @@ pub fn variant_eq(variant_a: &Variant, variant_b: &Variant) -> bool {
|
|||
(Variant::Float32(a), Variant::Float32(b)) => fuzzy_eq_f32(*a, *b),
|
||||
(Variant::Float64(a), Variant::Float64(b)) => fuzzy_eq_f64(*a, *b),
|
||||
(Variant::Font(a), Variant::Font(b)) => {
|
||||
a.weight == b.weight
|
||||
&& a.style == b.style
|
||||
&& a.family == b.family
|
||||
&& a.cached_face_id == b.cached_face_id
|
||||
a.weight == b.weight && a.style == b.style && a.family == b.family
|
||||
}
|
||||
(Variant::Int32(a), Variant::Int32(b)) => a == b,
|
||||
(Variant::Int64(a), Variant::Int64(b)) => a == b,
|
||||
|
|
@ -329,10 +326,7 @@ pub fn variant_eq_disk(variant_a: &Variant, variant_b: &Variant) -> bool {
|
|||
(Variant::Float32(a), Variant::Float32(b)) => disk_eq_f32(*a, *b),
|
||||
(Variant::Float64(a), Variant::Float64(b)) => disk_eq_f64(*a, *b),
|
||||
(Variant::Font(a), Variant::Font(b)) => {
|
||||
a.weight == b.weight
|
||||
&& a.style == b.style
|
||||
&& a.family == b.family
|
||||
&& a.cached_face_id == b.cached_face_id
|
||||
a.weight == b.weight && a.style == b.style && a.family == b.family
|
||||
}
|
||||
(Variant::Int32(a), Variant::Int32(b)) => a == b,
|
||||
(Variant::Int64(a), Variant::Int64(b)) => a == b,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue