mirror of
https://github.com/ashinn/chibi-scheme.git
synced 2025-05-19 05:39:18 +02:00
restoring hashing of trailing data for uvectors
This commit is contained in:
parent
b4520b31f5
commit
449312d3bd
1 changed files with 10 additions and 3 deletions
|
@ -48,10 +48,10 @@ sexp sexp_string_ci_hash (sexp ctx, sexp self, sexp_sint_t n, sexp str, sexp bou
|
||||||
}
|
}
|
||||||
|
|
||||||
static sexp_uint_t hash_one (sexp ctx, sexp obj, sexp_uint_t bound, sexp_sint_t depth) {
|
static sexp_uint_t hash_one (sexp ctx, sexp obj, sexp_uint_t bound, sexp_sint_t depth) {
|
||||||
sexp_uint_t acc = FNV_OFFSET_BASIS;
|
sexp_uint_t acc = FNV_OFFSET_BASIS, right_size;
|
||||||
sexp_sint_t i, len;
|
sexp_sint_t i, len;
|
||||||
sexp t, *p;
|
sexp t, *p;
|
||||||
char *p0;
|
char *p0, *p_right;
|
||||||
loop:
|
loop:
|
||||||
if (obj) {
|
if (obj) {
|
||||||
#if SEXP_USE_FLONUMS
|
#if SEXP_USE_FLONUMS
|
||||||
|
@ -64,8 +64,15 @@ static sexp_uint_t hash_one (sexp ctx, sexp obj, sexp_uint_t bound, sexp_sint_t
|
||||||
t = sexp_object_type(ctx, obj);
|
t = sexp_object_type(ctx, obj);
|
||||||
p = (sexp*) (((char*)obj) + sexp_type_field_base(t));
|
p = (sexp*) (((char*)obj) + sexp_type_field_base(t));
|
||||||
p0 = ((char*)obj) + offsetof(struct sexp_struct, value);
|
p0 = ((char*)obj) + offsetof(struct sexp_struct, value);
|
||||||
|
/* if the field_base is 0, skip to the value */
|
||||||
if ((sexp)p == obj) p=(sexp*)p0;
|
if ((sexp)p == obj) p=(sexp*)p0;
|
||||||
/* hash only eq-object slots */
|
/* hash uvector data (otherwise strings all hash to the same value) */
|
||||||
|
if (sexp_bytesp(obj) || sexp_uvectorp(obj)) {
|
||||||
|
p_right = ((char*)p + sexp_type_num_slots_of_object(t, obj)*sizeof(sexp));
|
||||||
|
right_size = ((char*)obj + sexp_type_size_of_object(t, obj)) - p_right;
|
||||||
|
for (i=0; i<right_size; i++) {acc *= FNV_PRIME; acc ^= p_right[i];}
|
||||||
|
}
|
||||||
|
/* hash eq-object slots */
|
||||||
len = sexp_type_num_eq_slots_of_object(t, obj);
|
len = sexp_type_num_eq_slots_of_object(t, obj);
|
||||||
if (len > 0) {
|
if (len > 0) {
|
||||||
depth--;
|
depth--;
|
||||||
|
|
Loading…
Add table
Reference in a new issue