terminal/style: compare packed styles directly, no cast needed
Woohoo, Zig 0.14!pull/7451/head
parent
19db2e2755
commit
25a708ed98
|
|
@ -87,10 +87,9 @@ 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 {
|
||||||
const packed_self = PackedStyle.fromStyle(self);
|
// We convert the styles to packed structs and compare as integers
|
||||||
const packed_other = PackedStyle.fromStyle(other);
|
// because this is much faster than comparing each field separately.
|
||||||
// TODO: in Zig 0.14, equating packed structs is allowed. Remove this work around.
|
return PackedStyle.fromStyle(self) == PackedStyle.fromStyle(other);
|
||||||
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
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue