summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorlemon <lsof@mailbox.org>2022-10-09 13:06:25 +0200
committerlemon <lsof@mailbox.org>2022-10-09 13:06:25 +0200
commita8874ced3f222cc5f4ed963a09c3491ac36610a6 (patch)
treeb4dc442c78633387513513ebcdc4b0ea2c5148aa
parented34de7ff26e0077a8d00794e469f273ebdb5c4a (diff)
upval size optimization
-rw-r--r--pez.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/pez.c b/pez.c
index 40d097b..d965095 100644
--- a/pez.c
+++ b/pez.c
@@ -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;
}
}
}