From 8efa638110a05c2b9fcc72608d97d34993fba3d7 Mon Sep 17 00:00:00 2001 From: David Rubin Date: Tue, 24 Dec 2024 22:53:39 -0800 Subject: [PATCH] optimize `Style.eql` using `PackedStyle` --- src/terminal/style.zig | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/terminal/style.zig b/src/terminal/style.zig index b58a331965..6c1f8b6089 100644 --- a/src/terminal/style.zig +++ b/src/terminal/style.zig @@ -87,7 +87,10 @@ pub const Style = struct { /// True if the style is equal to another style. 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