Annotate all useTmp paths as unlikely

This commit is contained in:
2025-05-27 10:37:09 -04:00
parent 0027c9ff79
commit 7a3eb61868

View File

@@ -654,7 +654,7 @@ inline PRESERVE_NONE WeaselJsonStatus t_hex2(Parser3 *self) {
} else if (self->utf8Codepoint < 0x800) { } else if (self->utf8Codepoint < 0x800) {
bool useTmp = self->buf - self->writeBuf < 2; bool useTmp = self->buf - self->writeBuf < 2;
char *p = tmp; char *p = tmp;
if (useTmp) { if (useTmp) [[unlikely]] {
self->flushString(false); self->flushString(false);
} }
auto &w = useTmp ? p : self->writeBuf; auto &w = useTmp ? p : self->writeBuf;
@@ -662,7 +662,7 @@ inline PRESERVE_NONE WeaselJsonStatus t_hex2(Parser3 *self) {
self->utf8Codepoint >>= 6; self->utf8Codepoint >>= 6;
w[0] = (0b00011111 & self->utf8Codepoint) | 0b11000000; w[0] = (0b00011111 & self->utf8Codepoint) | 0b11000000;
w += 2; w += 2;
if (useTmp) { if (useTmp) [[unlikely]] {
self->callbacks->on_string_data(self->userdata, tmp, 2, false); self->callbacks->on_string_data(self->userdata, tmp, 2, false);
} }
} else { } else {
@@ -680,7 +680,7 @@ inline PRESERVE_NONE WeaselJsonStatus t_hex2(Parser3 *self) {
} }
bool useTmp = self->buf - self->writeBuf < 3; bool useTmp = self->buf - self->writeBuf < 3;
char *p = tmp; char *p = tmp;
if (useTmp) { if (useTmp) [[unlikely]] {
self->flushString(false); self->flushString(false);
} }
auto &w = useTmp ? p : self->writeBuf; auto &w = useTmp ? p : self->writeBuf;
@@ -690,7 +690,7 @@ inline PRESERVE_NONE WeaselJsonStatus t_hex2(Parser3 *self) {
self->utf8Codepoint >>= 6; self->utf8Codepoint >>= 6;
w[0] = (0b00001111 & self->utf8Codepoint) | 0b11100000; w[0] = (0b00001111 & self->utf8Codepoint) | 0b11100000;
w += 3; w += 3;
if (useTmp) { if (useTmp) [[unlikely]] {
self->callbacks->on_string_data(self->userdata, tmp, 3, false); self->callbacks->on_string_data(self->userdata, tmp, 3, false);
} }
} }
@@ -730,7 +730,7 @@ inline PRESERVE_NONE WeaselJsonStatus t_hex3(Parser3 *self) {
} }
bool useTmp = self->buf - self->writeBuf < 4; bool useTmp = self->buf - self->writeBuf < 4;
char *p = tmp; char *p = tmp;
if (useTmp) { if (useTmp) [[unlikely]] {
self->flushString(false); self->flushString(false);
} }
auto &w = useTmp ? p : self->writeBuf; auto &w = useTmp ? p : self->writeBuf;
@@ -742,7 +742,7 @@ inline PRESERVE_NONE WeaselJsonStatus t_hex3(Parser3 *self) {
self->utf8Codepoint >>= 6; self->utf8Codepoint >>= 6;
w[0] = (0b00000111 & self->utf8Codepoint) | 0b11110000; w[0] = (0b00000111 & self->utf8Codepoint) | 0b11110000;
w += 4; w += 4;
if (useTmp) { if (useTmp) [[unlikely]] {
self->callbacks->on_string_data(self->userdata, tmp, 4, false); self->callbacks->on_string_data(self->userdata, tmp, 4, false);
} }