more fixes on indexing code

git-svn-id: https://yap.svn.sf.net/svnroot/yap/trunk@883 b08c6af1-5177-4d33-ba66-4b1c6b8b522a
This commit is contained in:
vsc 2003-10-06 13:49:38 +00:00
parent cf148cd0cb
commit 32301f0060
4 changed files with 17 additions and 11 deletions

View File

@ -148,7 +148,7 @@ LookupAtom(char *atom)
/* compute hash */
p = (unsigned char *)atom;
HashFunction(p, hash);
hash = HashFunction(p) % MaxHash;
WRITE_LOCK(HashChain[hash].AERWLock);
a = HashChain[hash].Entry;
/* search atom in chain */
@ -196,7 +196,7 @@ Yap_LookupAtomWithAddress(char *atom, AtomEntry *ae)
/* compute hash */
p = (unsigned char *)atom;
HashFunction(p, hash);
hash = HashFunction(p) % MaxHash;
/* ask for a WRITE lock because it is highly unlikely we shall find anything */
WRITE_LOCK(HashChain[hash].AERWLock);
a = HashChain[hash].Entry;
@ -226,7 +226,7 @@ Yap_ReleaseAtom(Atom atom)
/* compute hash */
p = (unsigned char *)name;
HashFunction(p, hash);
hash = HashFunction(p) % MaxHash;
WRITE_LOCK(HashChain[hash].AERWLock);
if (HashChain[hash].Entry == atom) {
HashChain[hash].Entry = ap->NextOfAE;

View File

@ -4470,7 +4470,7 @@ kill_block(path_stack_entry *sp, PredEntry *ap)
}
static path_stack_entry *
kill_clause(yamop *ipc, path_stack_entry *sp, PredEntry *ap)
kill_clause(yamop *ipc, yamop *bg, yamop *lt, path_stack_entry *sp, PredEntry *ap)
{
LogUpdIndex *blk;
yamop *start;
@ -4498,11 +4498,11 @@ kill_clause(yamop *ipc, path_stack_entry *sp, PredEntry *ap)
case _retry:
case _try_clause:
/* kill block and replace by this single clause */
if (codep != ipc) {
if (!IN_BETWEEN(bg, codep->u.ld.d, lt)) {
path_stack_entry *nsp = sp;
while ((--nsp)->flag != block_entry);
*sp->u.cle.entry_code = ipc->u.ld.d;
*sp->u.cle.entry_code = codep->u.ld.d;
Yap_kill_iblock(sp->u.cle.block, nsp->u.cle.block, ap);
return sp;
} else {
@ -5472,7 +5472,7 @@ remove_from_index(PredEntry *ap, path_stack_entry *sp, ClauseDef *cls, yamop *bg
have to expand the index.
*/
if (IN_BETWEEN(bg,ipc->u.ld.d,lt)) {
sp = kill_clause(ipc, sp, ap);
sp = kill_clause(ipc, bg, lt, sp, ap);
ipc = pop_path(&sp, cls, ap);
} else {
/* just go to next instruction */
@ -5486,7 +5486,7 @@ remove_from_index(PredEntry *ap, path_stack_entry *sp, ClauseDef *cls, yamop *bg
ipc = NEXTOP(ipc, ld);
case _trust:
if (IN_BETWEEN(bg,ipc->u.ld.d,lt)) {
sp = kill_clause(ipc, sp, ap);
sp = kill_clause(ipc, bg, lt, sp, ap);
}
ipc = pop_path(&sp, cls, ap);
break;

View File

@ -121,10 +121,10 @@ Yap_LookupVar(char *var) /* lookup variable in variables table */
if (var[0] != '_' || var[1] != '\0') {
VarEntry **op = &Yap_VarTable;
unsigned char *vp = (unsigned char *)var;
CELL hv;
UInt hv;
p = Yap_VarTable;
HashFunction(vp, hv);
hv = HashFunction(vp) % MaxHash;
while (p != NULL) {
CELL hpv = p->hv;
if (hv == hpv) {

View File

@ -323,7 +323,13 @@ extern int Yap_Portray_delays;
#endif
#endif
#define HashFunction(CHP,OUT) { (OUT)=0; while(*(CHP) != '\0') (OUT) += *(CHP)++; (OUT) %= MaxHash; }
EXTERN inline UInt
HashFunction(char *CHP)
{
UInt OUT=0;
while(*CHP != '\0') OUT += (UInt)(*CHP++);
return OUT;
}
#define FAIL_ON_PARSER_ERROR 0
#define QUIET_ON_PARSER_ERROR 1