Move copying out of tight loop

This commit is contained in:
2025-05-19 19:49:11 -04:00
parent a4d7d1f91e
commit a890ce3666

View File

@@ -327,14 +327,27 @@ inline Status n_string(Parser3 *self) {
}
inline Status n_string2(Parser3 *self) {
auto commit = [self, before = self->buf]() {
int len = self->buf - before;
if (self->writeBuf != before) {
memmove(self->writeBuf, before, len);
}
self->writeBuf += len;
};
begin:
switch (tables.stringByteMeaning[uint8_t(*self->buf)]) {
case Tables::NORMAL:
*self->writeBuf++ = *self->buf++;
auto meaning = tables.stringByteMeaning[uint8_t(*self->buf)];
if (meaning == Tables::NORMAL) {
++self->buf;
if (self->buf == self->bufEnd) {
commit();
MUSTTAIL return Parser3::keepGoing(self);
}
goto begin;
}
commit();
switch (meaning) {
case Tables::NORMAL:
__builtin_unreachable();
case Tables::DUBQUOTE:
self->flushString();
self->callbacks->on_end_string(self->data);