optimize Style.eql using PackedStyle

This commit is contained in:
David Rubin
2024-12-24 22:53:39 -08:00
parent fddedd7c01
commit 8efa638110

View File

@ -87,7 +87,10 @@ pub const Style = struct {
/// True if the style is equal to another style. /// True if the style is equal to another style.
pub fn eql(self: Style, other: Style) bool { pub fn eql(self: Style, other: Style) bool {
return std.meta.eql(self, other); const packed_self = PackedStyle.fromStyle(self);
const packed_other = PackedStyle.fromStyle(other);
// TODO: in Zig 0.14, equating packed structs is allowed. Remove this work around.
return @as(u128, @bitCast(packed_self)) == @as(u128, @bitCast(packed_other));
} }
/// Returns the bg color for a cell with this style given the cell /// Returns the bg color for a cell with this style given the cell