1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-06-09 21:40:33 +02:00

scm_hasher: Use symbolic names for the tc3 constants and some SCM usage

cleanups.
This commit is contained in:
Dirk Herrmann 2000-04-10 14:29:26 +00:00
parent 3da01fa367
commit dba97178b1
2 changed files with 21 additions and 11 deletions

View file

@ -1,3 +1,9 @@
2000-04-10 Dirk Herrmann <D.Herrmann@tu-bs.de>
* hash.c (scm_hasher): Use symbolic names for the tc3 constants.
Unpack SCM value to use it as a switch parameter. Don't cast SCM
values to int values.
2000-04-10 Mikael Djurfeldt <mdj@mdj.nada.kth.se> 2000-04-10 Mikael Djurfeldt <mdj@mdj.nada.kth.se>
* coop.c (mother): Handled EINTR (the wait has been interrupted by * coop.c (mother): Handled EINTR (the wait has been interrupted by

View file

@ -59,29 +59,33 @@ extern double floor();
#endif #endif
/* Dirk:FIXME:: why downcase for characters? (2x: scm_hasher, scm_ihashv) */
/* Dirk:FIXME:: scm_hasher could be made static. */
unsigned long unsigned long
scm_hasher(SCM obj, unsigned long n, scm_sizet d) scm_hasher(SCM obj, unsigned long n, scm_sizet d)
{ {
switch (7 & (int) obj) { switch (SCM_ITAG3 (obj)) {
case 2: case scm_tc3_int_1:
case 6: case scm_tc3_int_2:
return SCM_INUM(obj) % n; /* SCM_INUMP(obj) */ return SCM_INUM(obj) % n; /* SCM_INUMP(obj) */
case 4: case scm_tc3_imm24:
if SCM_CHARP(obj) if (SCM_CHARP(obj))
return (unsigned)(scm_downcase(SCM_CHAR(obj))) % n; return (unsigned)(scm_downcase(SCM_CHAR(obj))) % n;
switch ((int) obj) { switch (SCM_UNPACK (obj)) {
#ifndef SICP #ifndef SICP
case (int) SCM_EOL: case SCM_EOL:
d = 256; d = 256;
break; break;
#endif #endif
case (int) SCM_BOOL_T: case SCM_BOOL_T:
d = 257; d = 257;
break; break;
case (int) SCM_BOOL_F: case SCM_BOOL_F:
d = 258; d = 258;
break; break;
case (int) SCM_EOF_VAL: case SCM_EOF_VAL:
d = 259; d = 259;
break; break;
default: default:
@ -90,7 +94,7 @@ scm_hasher(SCM obj, unsigned long n, scm_sizet d)
return d % n; return d % n;
default: default:
return 263 % n; /* perhaps should be error */ return 263 % n; /* perhaps should be error */
case 0: case scm_tc3_cons:
switch SCM_TYP7(obj) { switch SCM_TYP7(obj) {
default: default:
return 263 % n; return 263 % n;