This commit is contained in:
Francesco Cozzuto
2021-11-04 17:27:06 +01:00
parent 0157d28f67
commit b224f57361
5 changed files with 8 additions and 25 deletions
+1 -1
View File
@@ -5,6 +5,6 @@ fun x(a, b, c)
x(1, 2, 3, 4, 5); x(1, 2, 3, 4, 5);
x(1, 2, 3, 4); x(1, 2, 3, 4);
x(1, 2, 3); x(1, 2, 3);
x(1, 2); # Fails here! x(1, 2);
x(1); x(1);
x(); x();
+3 -4
View File
@@ -1,7 +1,6 @@
l = [1, 2, 3]; l = [1, 2, 3, 4];
print(count); print('The list contains ', count(l), ' items.\n');
print(count(l)); print('The list is: ', l, '.\n');
print(l, '\n');
+2 -15
View File
@@ -76,10 +76,6 @@ static Object *select(Object *self, Object *key, Heap *heap, Error *error)
assert(heap != NULL); assert(heap != NULL);
assert(error != NULL); assert(error != NULL);
fprintf(stderr, "Selecting from:\n\t");
Object_Print(self, stderr);
fprintf(stderr, "\n");
MapObject *map = (MapObject*) self; MapObject *map = (MapObject*) self;
int mask = map->mapper_size - 1; int mask = map->mapper_size - 1;
@@ -92,15 +88,10 @@ static Object *select(Object *self, Object *key, Heap *heap, Error *error)
int i = hash & mask; int i = hash & mask;
#warning "TEMP"
fprintf(stderr, "-----------------\n");
while(1) while(1)
{ {
int k = map->mapper[i]; int k = map->mapper[i];
fprintf(stderr, "map->mapper[%d] = %d\n", i, k);
if(k == -1) if(k == -1)
{ {
// Empty slot. // Empty slot.
@@ -113,10 +104,6 @@ static Object *select(Object *self, Object *key, Heap *heap, Error *error)
// Is it the right one? // Is it the right one?
assert(k >= 0); assert(k >= 0);
#warning "TEMP"
fprintf(stderr, "map->keys[%d] = ", k);
Object_Print(map->keys[k], stderr);
fprintf(stderr, " (of type %s)\n", Object_GetName(map->keys[k]));
if(Object_Compare(key, map->keys[k], error)) if(Object_Compare(key, map->keys[k], error))
// Found it! // Found it!
@@ -133,8 +120,6 @@ static Object *select(Object *self, Object *key, Heap *heap, Error *error)
pert >>= 5; pert >>= 5;
i = (i * 5 + pert + 1) & mask; i = (i * 5 + pert + 1) & mask;
fprintf(stderr, "%d -> %d\n", old_i, i);
} }
UNREACHABLE; UNREACHABLE;
@@ -264,6 +249,8 @@ static _Bool insert(Object *self, Object *key, Object *val, Heap *heap, Error *e
// Collision. // Collision.
} }
int old_i = i;
pert >>= 5; pert >>= 5;
i = (i * 5 + pert + 1) & mask; i = (i * 5 + pert + 1) & mask;
} }
-3
View File
@@ -96,9 +96,6 @@ static _Bool op_eql(Object *self, Object *other)
_Bool match = s1->size == s2->size && !strncmp(s1->body, s2->body, s1->size); _Bool match = s1->size == s2->size && !strncmp(s1->body, s2->body, s1->size);
#warning "TEMP"
fprintf(stderr, "%s == %s ? %s\n", s1->body, s2->body, match ? "yes" : "no");
return match; return match;
} }
+1 -1
View File
@@ -3,7 +3,7 @@
int hashbytes(unsigned char *str, int len) int hashbytes(unsigned char *str, int len)
{ {
int x = (intptr_t) str; // just to not use 0. int x = 0; // Temp?
x ^= *str << 7; x ^= *str << 7;