Unsafe (length)

This commit is contained in:
Justin Ethier 2019-11-26 23:06:01 -05:00
parent 488cdf26cc
commit f091d0267e
3 changed files with 15 additions and 1 deletions

View file

@ -836,6 +836,7 @@ object Cyc_set_cell(void *, object l, object val);
object Cyc_set_car(void *, object l, object val);
object Cyc_set_cdr(void *, object l, object val);
object Cyc_length(void *d, object l);
object Cyc_length_unsafe(void *d, object l);
object Cyc_list2vector(void *data, object cont, object l);
object Cyc_list2string(void *d, object cont, object lst);
object Cyc_list(void *data, int argc, object cont, ...);

View file

@ -2002,6 +2002,16 @@ object Cyc_length(void *data, object l)
return obj_int2obj(len);
}
object Cyc_length_unsafe(void *data, object l)
{
int len = 0;
while (l != NULL) {
l = cdr(l);
len++;
}
return obj_int2obj(len);
}
char *int_to_binary(char *b, int x)
{
unsigned int i = 0x80000000, leading_zeros = 1;

View file

@ -646,7 +646,10 @@
((eq? p 'Cyc-compilation-environment) "Cyc_compilation_environment")
((eq? p 'command-line-arguments) "Cyc_command_line_arguments")
((eq? p 'system) "Cyc_system")
((eq? p 'length) "Cyc_length")
((eq? p 'length)
(if emit-unsafe
"Cyc_length_unsafe"
"Cyc_length"))
((eq? p 'set-car!) "Cyc_set_car")
((eq? p 'set-cdr!) "Cyc_set_cdr")
((eq? p 'eq?) "Cyc_eq")