From c4aac28a426351c7718c605e0c06d9e69b60772e Mon Sep 17 00:00:00 2001 From: r00ster Date: Fri, 8 Apr 2022 18:15:57 +0200 Subject: [PATCH] Reuse code in `Utf8Iterator.nextCodepoint` --- lib/std/unicode.zig | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/lib/std/unicode.zig b/lib/std/unicode.zig index e0a000dfe5..487f3defdf 100644 --- a/lib/std/unicode.zig +++ b/lib/std/unicode.zig @@ -269,14 +269,7 @@ pub const Utf8Iterator = struct { pub fn nextCodepoint(it: *Utf8Iterator) ?u21 { const slice = it.nextCodepointSlice() orelse return null; - - switch (slice.len) { - 1 => return @as(u21, slice[0]), - 2 => return utf8Decode2(slice) catch unreachable, - 3 => return utf8Decode3(slice) catch unreachable, - 4 => return utf8Decode4(slice) catch unreachable, - else => unreachable, - } + return utf8Decode(slice) catch unreachable; } /// Look ahead at the next n codepoints without advancing the iterator.