mirror of
				https://github.com/janet-lang/janet
				synced 2025-10-31 15:43:01 +00:00 
			
		
		
		
	Make janet_equals and janet_compare non recursive
This makes these operatios use constant stack space rather than linear stackspace given the size of the inputs. This is important to prevent certain parser input from causing a stack overflow - in general, we try to avoid unbounded recursion.
This commit is contained in:
		| @@ -50,5 +50,20 @@ int system_test() { | ||||
|     assert(janet_equals(janet_cstringv("a string."), janet_cstringv("a string."))); | ||||
|     assert(janet_equals(janet_csymbolv("sym"), janet_csymbolv("sym"))); | ||||
|  | ||||
|     Janet *t1 = janet_tuple_begin(3); | ||||
|     t1[0] = janet_wrap_nil(); | ||||
|     t1[1] = janet_wrap_integer(4); | ||||
|     t1[2] = janet_cstringv("hi"); | ||||
|     Janet tuple1 = janet_wrap_tuple(janet_tuple_end(t1)); | ||||
|  | ||||
|     Janet *t2 = janet_tuple_begin(3); | ||||
|     t2[0] = janet_wrap_nil(); | ||||
|     t2[1] = janet_wrap_integer(4); | ||||
|     t2[2] = janet_cstringv("hi"); | ||||
|     Janet tuple2 = janet_wrap_tuple(janet_tuple_end(t2)); | ||||
|  | ||||
|     assert(janet_equals(tuple1, tuple2)); | ||||
|  | ||||
|  | ||||
|     return 0; | ||||
| } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Calvin Rose
					Calvin Rose