mirror of
https://gitlab.com/embeddable-common-lisp/ecl.git
synced 2026-03-10 23:20:23 -07:00
Improved hashing with unicode. Random states can now be compared and have similar keys when equalp
This commit is contained in:
parent
e83d8282ed
commit
c7052c977a
6 changed files with 15 additions and 9 deletions
|
|
@ -55,6 +55,9 @@ ECL 0.9k:
|
|||
|
||||
- Building a statically linked ECL works again.
|
||||
|
||||
- Equal random states now compare properly under EQUALP and their hash keys
|
||||
are also equal.
|
||||
|
||||
;;; Local Variables: ***
|
||||
;;; mode:text ***
|
||||
;;; fill-column:79 ***
|
||||
|
|
|
|||
|
|
@ -98,9 +98,7 @@ _hash_equal(int depth, cl_hashkey h, cl_object x)
|
|||
h = _hash_equal(depth, h, x->pathname.directory);
|
||||
h = _hash_equal(depth, h, x->pathname.name);
|
||||
h = _hash_equal(depth, h, x->pathname.type);
|
||||
return _hash_equal(depth, h, x->pathname.name);
|
||||
case t_random:
|
||||
return hash_word(h, x->random.value);
|
||||
return _hash_equal(depth, h, x->pathname.version);
|
||||
case t_bitvector:
|
||||
/* Notice that we may round out some bits. We must do this
|
||||
* because the fill pointer may be set in the middle of a byte.
|
||||
|
|
@ -108,6 +106,8 @@ _hash_equal(int depth, cl_hashkey h, cl_object x)
|
|||
* because otherwise two bit arrays which are EQUAL might
|
||||
* have different hash keys. */
|
||||
return hash_string(h, x->vector.self.ch, x->vector.fillp / 8);
|
||||
case t_random:
|
||||
return _hash_equal(depth, h, x->random.value);
|
||||
default:
|
||||
return _hash_eql(h, x);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -138,9 +138,9 @@ hash_string(cl_index initval, const unsigned char *k, cl_index len)
|
|||
}
|
||||
#endif
|
||||
|
||||
static cl_index hash_word(cl_index c, cl_index a)
|
||||
static cl_index hash_word(cl_index c, cl_index w)
|
||||
{
|
||||
cl_index b = GOLDEN_RATIO;
|
||||
cl_index a = w + GOLDEN_RATIO, b = GOLDEN_RATIO;
|
||||
mix(a, b, c);
|
||||
return c;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -62,8 +62,9 @@ generate_double(cl_object rs)
|
|||
cl_object
|
||||
init_random_state()
|
||||
{
|
||||
cl_object a = ecl_alloc_simple_vector(MT_N + 1, aet_index);
|
||||
ulong *mt = a->vector.self.index;
|
||||
cl_index bytes = sizeof(ulong) * (MT_N + 1);
|
||||
cl_object a = cl_alloc_simple_base_string(bytes);
|
||||
ulong *mt = (ulong*)a->base_string.self;
|
||||
int j;
|
||||
#if !defined(_MSC_VER) && !defined(mingw32)
|
||||
FILE *fp = fopen("/dev/urandom","r");
|
||||
|
|
@ -92,7 +93,7 @@ generate_int32(cl_object state)
|
|||
{
|
||||
static ulong mag01[2]={0x0UL, MATRIX_A};
|
||||
ulong y;
|
||||
ulong *mt = state->vector.self.index;
|
||||
ulong *mt = (ulong*)state->base_string.self;
|
||||
if (mt[MT_N] >= MT_N){
|
||||
/* refresh data */
|
||||
int kk;
|
||||
|
|
|
|||
|
|
@ -500,6 +500,8 @@ BEGIN:
|
|||
}
|
||||
return TRUE;
|
||||
}
|
||||
case t_random:
|
||||
return ecl_equalp(x->random.value, y->random.value);
|
||||
default:
|
||||
return FALSE;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ Returns, as a string, the location of the machine on which ECL runs."
|
|||
(defun lisp-implementation-version ()
|
||||
"Args:()
|
||||
Returns the version of your ECL as a string."
|
||||
"@PACKAGE_VERSION@ (CVS 2008-02-01 20:07)")
|
||||
"@PACKAGE_VERSION@ (CVS 2008-02-02 20:05)")
|
||||
|
||||
(defun machine-type ()
|
||||
"Args: ()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue