diff options
author | Aleksey Veresov <aleksey@veresov.pro> | 2021-01-09 21:44:21 +0300 |
---|---|---|
committer | Aleksey Veresov <aleksey@veresov.pro> | 2021-01-09 21:44:21 +0300 |
commit | a0f273300aec59d31eb332e531efd8249fc67f20 (patch) | |
tree | bc97d57116225977c374721f8517611156aaf6ec /src/csx.c | |
parent | ff592daf2d90b922f82e65f648caf27381f89590 (diff) | |
download | csx-a0f273300aec59d31eb332e531efd8249fc67f20.tar csx-a0f273300aec59d31eb332e531efd8249fc67f20.tar.xz csx-a0f273300aec59d31eb332e531efd8249fc67f20.zip |
Performance improvements.
Diffstat (limited to 'src/csx.c')
-rw-r--r-- | src/csx.c | 18 |
1 files changed, 5 insertions, 13 deletions
@@ -188,26 +188,14 @@ csx_base_data *csx_base(csx_base_data base) int *csx_int(int num) { if (!initiated) init(); - int i; - for (i = 0; i != objslen; ++i) { - int *obj = (int *)(objs[i]) + 2; - if (type(obj) != type_int) continue; - if (*obj == num) return obj; - } int *res = new(type_int, sizeof(int)); *res = num; return res; } -double *csx_float(double num) +double *csx_real(double num) { if (!initiated) init(); - int i; - for (i = 0; i != objslen; ++i) { - double *obj = (void *)((int *)(objs[i]) + 2); - if (type(obj) != type_real) continue; - if (*obj == num) return obj; - } double *res = new(type_real, sizeof(double)); *res = num; return res; @@ -336,6 +324,10 @@ static void *base_quote(void *arg) static void *base_same(void *arg) { arg = run_each(arg); + if (type(head(arg)) == type_int) + return *(int *)head(arg) == *(int *)head(tail(arg)) ? one : null; + if (type(head(arg)) == type_real) + return *(double *)head(arg) == *(double *)head(tail(arg)) ? one : null; return head(arg) == head(tail(arg)) ? one : null; } |