Compare fields directly instead of PackedStyle

Comparing the fields directly is actually faster than PackedStyle
pull/8489/head
Jesse Miller 2025-09-02 12:05:30 -06:00
parent a51a956bdb
commit 7dcf2c9b62
1 changed files with 4 additions and 3 deletions

View File

@ -85,9 +85,10 @@ pub const Style = struct {
/// True if the style is equal to another style.
pub fn eql(self: Style, other: Style) bool {
// We convert the styles to packed structs and compare as integers
// because this is much faster than comparing each field separately.
return PackedStyle.fromStyle(self) == PackedStyle.fromStyle(other);
return @as(u16, @bitCast(self.flags)) == @as(u16, @bitCast(other.flags)) and
std.meta.eql(self.fg_color, other.fg_color) and
std.meta.eql(self.bg_color, other.bg_color) and
std.meta.eql(self.underline_color, other.underline_color);
}
/// Returns the bg color for a cell with this style given the cell