Compare fields directly instead of PackedStyle
Comparing the fields directly is actually faster than PackedStylepull/8489/head
parent
a51a956bdb
commit
7dcf2c9b62
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Reference in New Issue