From 88d57917b7df1f0c59d27a923bd564f5d21f7846 Mon Sep 17 00:00:00 2001 From: Rohan Vashisht <81112205+RohanVashisht1234@users.noreply.github.com> Date: Sat, 30 Nov 2024 01:56:23 +0530 Subject: [PATCH] Updated ascii.zig's isWhitespace function to use switch instead of for loop. (#22094) --- lib/std/ascii.zig | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/std/ascii.zig b/lib/std/ascii.zig index 7b99f6f4cf..6f466e0a6a 100644 --- a/lib/std/ascii.zig +++ b/lib/std/ascii.zig @@ -135,10 +135,10 @@ pub fn isPrint(c: u8) bool { /// Returns whether this character is included in `whitespace`. pub fn isWhitespace(c: u8) bool { - return for (whitespace) |other| { - if (c == other) - break true; - } else false; + return switch (c) { + ' ', '\t'...'\r' => true, + else => false, + }; } /// Whitespace for general use.