shithub: femtolisp

Download patch

ref: 2282a527e0baad565075bdeb574b5b0b69f6f1d4
parent: 05f265f21c70dc51ada39404ab73de5b34eeffbf
author: Sigrid Solveig Haflínudóttir <sigrid@ftrv.se>
date: Wed Dec 18 21:12:07 EST 2024

apply_cl: simpler

--- a/flisp.c
+++ b/flisp.c
@@ -876,7 +876,8 @@
 	USED(n);
 	USED(v);
 apply_cl_top:
-	func = FL(stack)[FL(sp)-nargs-1];
+	bp = FL(sp)-nargs;
+	func = FL(stack)[bp-1];
 	ip = cvalue_data(fn_bcode(func));
 	assert(!ismanaged((uintptr_t)ip));
 	i = FL(sp)+GET_INT32(ip);
@@ -884,7 +885,6 @@
 		grow_stack();
 	ip += 4;
 
-	bp = FL(sp)-nargs;
 	PUSH(fn_env(func));
 	PUSH(FL(curr_frame));
 	PUSH(nargs);
@@ -1086,10 +1086,10 @@
 					}
 				}
 			}else if(__likely(iscbuiltin(func))){
-				s = FL(sp);
-				v = (((builtin_t*)ptr(func))[3])(&FL(stack)[FL(sp)-n], n);
-				FL(sp) = s-n;
-				FL(stack)[FL(sp)-1] = v;
+				s = FL(sp) - n;
+				v = (((builtin_t*)ptr(func))[3])(&FL(stack)[s], n);
+				FL(sp) = s;
+				FL(stack)[s-1] = v;
 				NEXT_OP;
 			}
 			type_error("function", func);