core: vector_to_list: Create less garbage.

* src/vector.c (vector_to_list): Create less garbage.
This commit is contained in:
Jan Nieuwenhuizen 2018-04-20 13:22:47 +02:00
parent 3330948a90
commit 62a369e6de
No known key found for this signature in database
GPG Key ID: F3C1A0D9C1D65273
1 changed files with 5 additions and 4 deletions

View File

@ -23,7 +23,8 @@ make_vector__ (int k)
{
SCM v = alloc (k);
SCM x = make_cell__ (TVECTOR, k, v);
for (int i=0; i<k; i++) g_cells[v+i] = g_cells[vector_entry (cell_unspecified)];
for (int i=0; i<k; i++)
g_cells[v+i] = g_cells[vector_entry (cell_unspecified)];
return x;
}
@ -90,12 +91,12 @@ SCM
vector_to_list (SCM v)
{
SCM x = cell_nil;
for (int i = 0; i < LENGTH (v); i++)
for (int i = LENGTH (v); i; i--)
{
SCM e = VECTOR (v)+i;
SCM e = VECTOR (v)+i-1;
if (TYPE (e) == TREF)
e = REF (e);
x = append2 (x, cons (e, cell_nil));
x = cons (e, x);
}
return x;
}