less memory usage of pic_reverse
This commit is contained in:
parent
00fc0ee931
commit
05b2717b9e
|
@ -96,10 +96,16 @@ pic_length(pic_state *pic, pic_value obj)
|
||||||
pic_value
|
pic_value
|
||||||
pic_reverse(pic_state *pic, pic_value list)
|
pic_reverse(pic_state *pic, pic_value list)
|
||||||
{
|
{
|
||||||
pic_value v, acc = pic_nil_value();
|
int ai = pic_gc_arena_preserve(pic);
|
||||||
|
pic_value v, acc;
|
||||||
|
|
||||||
|
acc = pic_nil_value();
|
||||||
for (v = list; ! pic_nil_p(v); v = pic_cdr(pic ,v)) {
|
for (v = list; ! pic_nil_p(v); v = pic_cdr(pic ,v)) {
|
||||||
acc = pic_cons(pic, pic_car(pic, v), acc);
|
acc = pic_cons(pic, pic_car(pic, v), acc);
|
||||||
|
|
||||||
|
pic_gc_arena_restore(pic, ai);
|
||||||
|
pic_gc_protect(pic, acc);
|
||||||
|
pic_gc_protect(pic, v);
|
||||||
}
|
}
|
||||||
return acc;
|
return acc;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue