authorgravatar for r00ster91@protonmail.comr00ster <r00ster91@protonmail.com> 2022-04-08 18:15:57+02:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2022-04-12 05:34:12-04:00
logc4aac28a426351c7718c605e0c06d9e69b60772e
tree4ecccb4370866833d679fcabda43d75aed5326f4
parent988afd51cd34649887f493b6ac9e05fcaa1f768d

Reuse code in `Utf8Iterator.nextCodepoint`


1 files changed, 1 insertions(+), 8 deletions(-)

lib/std/unicode.zig+1-8
......@@ -269,14 +269,7 @@ pub const Utf8Iterator = struct {
269269
270270 pub fn nextCodepoint(it: *Utf8Iterator) ?u21 {
271271 const slice = it.nextCodepointSlice() orelse return null;
272
273 switch (slice.len) {
274 1 => return @as(u21, slice[0]),
275 2 => return utf8Decode2(slice) catch unreachable,
276 3 => return utf8Decode3(slice) catch unreachable,
277 4 => return utf8Decode4(slice) catch unreachable,
278 else => unreachable,
279 }
272 return utf8Decode(slice) catch unreachable;
280273 }
281274
282275 /// Look ahead at the next n codepoints without advancing the iterator.