diff options
| author | 2022-10-09 13:06:25 +0200 | |
|---|---|---|
| committer | 2022-10-09 13:06:25 +0200 | |
| commit | a8874ced3f222cc5f4ed963a09c3491ac36610a6 (patch) | |
| tree | b4dc442c78633387513513ebcdc4b0ea2c5148aa /pez.c | |
| parent | ed34de7ff26e0077a8d00794e469f273ebdb5c4a (diff) | |
upval size optimization
Diffstat (limited to 'pez.c')
| -rw-r--r-- | pez.c | 11 |
1 files changed, 7 insertions, 4 deletions
@@ -86,9 +86,11 @@ typedef struct Proto { typedef struct Upval Upval; struct Upval { OBJHEADER; - Upval *nextup; Val *ptr; - Val slot; + union { + Upval *nextup; + Val slot; + }; }; typedef struct Fn { @@ -471,11 +473,12 @@ delproto(PezContext *cx, Proto *pr) static void closeups(PezContext *cx, Val *vals) { - for (Upval *up = cx->openup; up; up = up->nextup) { + for (Upval *up = cx->openup, *next; up; up = next) { + next = up->nextup; if (up->ptr >= vals) { + cx->openup = next; up->slot = *up->ptr; up->ptr = &up->slot; - cx->openup = up->nextup; } } } |