Eliminate some magic numbers

This commit is contained in:
Isaac Freund 2020-06-02 17:02:03 +02:00
parent ea7f5d4064
commit 03fc51d8d6
No known key found for this signature in database
GPG key ID: 86DED400DDFD7A11
2 changed files with 6 additions and 5 deletions

View file

@ -137,7 +137,7 @@ fn startTransaction(self: *Self) void {
var output_it = self.outputs.first;
while (output_it) |node| : (output_it = node.next) {
const output = &node.data;
var view_it = ViewStack(View).iterator(output.views.first, 0xFFFFFFFF);
var view_it = ViewStack(View).iterator(output.views.first, std.math.maxInt(u32));
while (view_it.next()) |view_node| {
const view = &view_node.view;
// Clear the serial in case this transaction is interrupting a prior one.
@ -222,7 +222,7 @@ fn commitTransaction(self: *Self) void {
output.pending_focused_tags = null;
}
var view_it = ViewStack(View).iterator(output.views.first, 0xFFFFFFFF);
var view_it = ViewStack(View).iterator(output.views.first, std.math.maxInt(u32));
while (view_it.next()) |view_node| {
const view = &view_node.view;
// Ensure that all pending state is cleared

View file

@ -275,7 +275,8 @@ test "push/remove (*View)" {
test "iteration (View)" {
const c = @import("c.zig");
const testing = @import("std").testing;
const std = @import("std");
const testing = std.testing;
const allocator = testing.allocator;
@ -315,7 +316,7 @@ test "iteration (View)" {
// Iteration over all tags
{
var it = ViewStack(View).iterator(views.first, 0xFFFFFFFF);
var it = ViewStack(View).iterator(views.first, std.math.maxInt(u32));
testing.expect((if (it.next()) |node| &node.view else null) == &two_a.view);
testing.expect((if (it.next()) |node| &node.view else null) == &five_b.view);
testing.expect((if (it.next()) |node| &node.view else null) == &four_b.view);
@ -349,7 +350,7 @@ test "iteration (View)" {
// Reverse iteration over all tags
{
var it = ViewStack(View).reverseIterator(views.last, 0xFFFFFFFF);
var it = ViewStack(View).reverseIterator(views.last, std.math.maxInt(u32));
testing.expect((if (it.next()) |node| &node.view else null) == &three_b_pa.view);
testing.expect((if (it.next()) |node| &node.view else null) == &one_a_pb.view);
testing.expect((if (it.next()) |node| &node.view else null) == &four_b.view);