Skip to content

Commit

Permalink
optimize Style.eql using PackedStyle (ghostty-org#3113)
Browse files Browse the repository at this point in the history
A follow-up on ghostty-org#3103, the `Style.eql` function can also benefit from
`PackedStyle`.

Using the same DFZ benchmark,
New: 795 FPS
Old (fddedd7): 765 FPS

FPS is a bit different due to differing background system loads, but the
increase in FPS is consistent across benchmarks.
  • Loading branch information
mitchellh authored Dec 25, 2024
2 parents fddedd7 + 8efa638 commit 8de95f6
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/terminal/style.zig
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 8de95f6

Please sign in to comment.