mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-07-16 08:46:08 +03:00
asserts not being optimized away, use comptime gate
This commit is contained in:
@ -286,22 +286,26 @@ pub const RowIndex = union(RowIndexTag) {
|
|||||||
pub fn toScreen(self: RowIndex, screen: *const Screen) RowIndex {
|
pub fn toScreen(self: RowIndex, screen: *const Screen) RowIndex {
|
||||||
const y = switch (self) {
|
const y = switch (self) {
|
||||||
.screen => |y| y: {
|
.screen => |y| y: {
|
||||||
assert(y < RowIndexTag.screen.maxLen(screen));
|
// NOTE for this and others below: Zig is supposed to optimize
|
||||||
|
// away assert in releasefast but for some reason these were
|
||||||
|
// not being optimized away. I don't know why. For these asserts
|
||||||
|
// only, I comptime gate them.
|
||||||
|
if (std.debug.runtime_safety) assert(y < RowIndexTag.screen.maxLen(screen));
|
||||||
break :y y;
|
break :y y;
|
||||||
},
|
},
|
||||||
|
|
||||||
.viewport => |y| y: {
|
.viewport => |y| y: {
|
||||||
assert(y < RowIndexTag.viewport.maxLen(screen));
|
if (std.debug.runtime_safety) assert(y < RowIndexTag.viewport.maxLen(screen));
|
||||||
break :y y + screen.viewport;
|
break :y y + screen.viewport;
|
||||||
},
|
},
|
||||||
|
|
||||||
.active => |y| y: {
|
.active => |y| y: {
|
||||||
assert(y < RowIndexTag.active.maxLen(screen));
|
if (std.debug.runtime_safety) assert(y < RowIndexTag.active.maxLen(screen));
|
||||||
break :y screen.history + y;
|
break :y screen.history + y;
|
||||||
},
|
},
|
||||||
|
|
||||||
.history => |y| y: {
|
.history => |y| y: {
|
||||||
assert(y < RowIndexTag.history.maxLen(screen));
|
if (std.debug.runtime_safety) assert(y < RowIndexTag.history.maxLen(screen));
|
||||||
break :y y;
|
break :y y;
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
Reference in New Issue
Block a user