You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This function uses ~1Kb of stack (with optimisations)
function test() -> [u8,...256]{let x :[u8, ..256];let val = get_val();if val == 0{
x = [1, ..256];return x;}elseif val == 1{
x = [4, ..256];return x;}else{
x = [9, ..256];return x;}}
While this function uses ~256 bytes of stack:
function test() -> [u8,...256]{let x :[u8, ..256];let val = get_val();if val == 0{
x = [1, ..256];}elseif val == 1{
x = [4, ..256];}else{
x = [9, ..256];}return x;}
As far as I can tell, each return statement gets given it's own slot which is copied into the return pointer at the end. This happens to also result in 4 memcpy calls in total.