Skip to content
Snippets Groups Projects
Commit c002d9fa authored by Yorhel's avatar Yorhel
Browse files

Work around a Zig ReleaseSafe mode performance regression

With a little help from IRC:

<ifreund> Ayo: its probaly stupidly copying that array to the stack to do the
          safety check, pretty sure there's an open issue on this still
<ifreund> you may be able to work around the compiler's stupidity by using a
          pointer to the array or slice or something
<Ayo> ifreund: Yup, (&self.rdbuf)[self.rdoff] does the trick, thanks.
<ifreund> no problem! should get fixed eventually
parent cebaaf09
Branches
Tags
No related merge requests found
......@@ -615,7 +615,10 @@ const Import = struct {
return;
}
}
self.ch = self.rdbuf[self.rdoff];
// Zig 0.10 copies the entire array to the stack in ReleaseSafe mode,
// work around that bug by indexing into a pointer to the array
// instead.
self.ch = (&self.rdbuf)[self.rdoff];
self.rdoff += 1;
self.byte += 1;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment