Skip to content

Commit 11b7131

Browse files
committed
perf: add HEDLEY_PURE to o_val and o_len accessors
o_val and o_len are stateless field accessors with no side effects. Annotating them as HEDLEY_PURE lets the compiler CSE repeated calls in hot loops, particularly o_len in ZK witness generation paths.
1 parent 6ca7482 commit 11b7131

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

src/zen_octet.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -369,8 +369,8 @@ octet *o_push(lua_State *L, const char *buf, size_t len) {
369369

370370
// extern const char *o_val(const octet*);
371371
// extern size_t o_len(const octet*);
372-
const char *o_val(const octet *o) { return((const char*)o->val); }
373-
size_t o_len(const octet *o) { return(o->len); }
372+
HEDLEY_PURE const char *o_val(const octet *o) { return((const char*)o->val); }
373+
HEDLEY_PURE size_t o_len(const octet *o) { return(o->len); }
374374

375375
void push_buffer_to_octet(lua_State *L, char *p, size_t len) {
376376
octet* o = o_new(L, len); SAFEV(o, CREATE_OCT_ERR);

0 commit comments

Comments
 (0)