ref: 808b3dcb532487bd6bc7ec428aa9171dd901258d
parent: 5d8fd67bba2d59dc59203149d62764a98622e27c
author: Sigrid Solveig Haflínudóttir <[email protected]>
date: Tue Dec 3 22:53:11 EST 2024
for-each: just increment sp instead of pushing booleans
--- a/flisp.c
+++ b/flisp.c
@@ -2099,21 +2099,20 @@
BUILTIN("for-each", for_each)
{
- argcount(nargs, 2);
- intptr_t argSP = args-FL(stack);
- assert(argSP >= 0 && argSP < FL(nstack));
- if(FL(sp)+2 > FL(nstack))
- grow_stack();
- PUSH(FL(t));
- PUSH(FL(t));
- while(iscons(FL(stack)[argSP+1])){
- FL(stack)[FL(sp)-2] = FL(stack)[argSP];
- FL(stack)[FL(sp)-1] = car_(FL(stack)[argSP+1]);
- _applyn(1);
- FL(stack)[argSP+1] = cdr_(FL(stack)[argSP+1]);
- }
- POPN(2);
- return FL(t);
+ argcount(nargs, 2);
+ intptr_t argSP = args-FL(stack);
+ assert(argSP >= 0 && argSP < FL(nstack));
+ if(FL(sp)+2 > FL(nstack))
+ grow_stack();
+ FL(sp) += 2;
+ while(iscons(FL(stack)[argSP+1])){
+ FL(stack)[FL(sp)-2] = FL(stack)[argSP];
+ FL(stack)[FL(sp)-1] = car_(FL(stack)[argSP+1]);
+ _applyn(1);
+ FL(stack)[argSP+1] = cdr_(FL(stack)[argSP+1]);
+ }
+ POPN(2);
+ return FL(t);
}
BUILTIN("sleep", fl_sleep)