Skip to content

Commit 5490688

Browse files
author
r00ster91
committed
refactor: use std.ascii functions
1 parent e3b3eab commit 5490688

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

lib/std/zig/tokenizer.zig

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
const std = @import("../std.zig");
2-
const mem = std.mem;
32

43
pub const Token = struct {
54
tag: Tag,
@@ -350,7 +349,7 @@ pub const Tokenizer = struct {
350349

351350
pub fn init(buffer: [:0]const u8) Tokenizer {
352351
// Skip the UTF-8 BOM if present
353-
const src_start = if (mem.startsWith(u8, buffer, "\xEF\xBB\xBF")) 3 else @as(usize, 0);
352+
const src_start: usize = if (std.mem.startsWith(u8, buffer, "\xEF\xBB\xBF")) 3 else 0;
354353
return Tokenizer{
355354
.buffer = buffer,
356355
.index = src_start,
@@ -1433,8 +1432,8 @@ pub const Tokenizer = struct {
14331432

14341433
fn getInvalidCharacterLength(self: *Tokenizer) u3 {
14351434
const c0 = self.buffer[self.index];
1436-
if (c0 < 0x80) {
1437-
if (c0 < 0x20 or c0 == 0x7f) {
1435+
if (std.ascii.isASCII(c0)) {
1436+
if (std.ascii.isCntrl(c0)) {
14381437
// ascii control codes are never allowed
14391438
// (note that \n was checked before we got here)
14401439
return 1;

0 commit comments

Comments
 (0)