shithub: sl

Download patch

ref: 063bab70488f5abd3d5d975503d9c2e3aef16c05
parent: 29d0d1220775bccb44a53e2c4a4f274540493d12
author: Sigrid Solveig Haflínudóttir <sigrid@ftrv.se>
date: Tue Feb 4 12:25:23 EST 2025

table-foldl: allow table to be modified during folding

It's not like the check was doing much - not all cases
would be detected, regardless.

--- a/src/table.c
+++ b/src/table.c
@@ -183,14 +183,13 @@
 	fl_gc_handle(&zero);
 	fl_gc_handle(&t);
 	for(size_t i = 0; i < n; i += 2){
-		if(table[i+1] != HT_NOTFOUND){
-			zero = fl_applyn(3, f, (value_t)table[i], (value_t)table[i+1], zero);
-			// reload pointer
-			h = cvalue_data(t);
-			if(h->size != n)
-				lerrorf(FL_EnumerationError, "table modified");
-			table = h->table;
-		}
+		if(table[i+1] == HT_NOTFOUND)
+			continue;
+		zero = fl_applyn(3, f, (value_t)table[i], (value_t)table[i+1], zero);
+		// reload pointer
+		h = cvalue_data(t);
+		n = h->size;
+		table = h->table;
 	}
 	fl_free_gc_handles(3);
 	return zero;