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:
parent
cf148cd0cb
commit
32301f0060
@ -148,7 +148,7 @@ LookupAtom(char *atom)
|
|||||||
|
|
||||||
/* compute hash */
|
/* compute hash */
|
||||||
p = (unsigned char *)atom;
|
p = (unsigned char *)atom;
|
||||||
HashFunction(p, hash);
|
hash = HashFunction(p) % MaxHash;
|
||||||
WRITE_LOCK(HashChain[hash].AERWLock);
|
WRITE_LOCK(HashChain[hash].AERWLock);
|
||||||
a = HashChain[hash].Entry;
|
a = HashChain[hash].Entry;
|
||||||
/* search atom in chain */
|
/* search atom in chain */
|
||||||
@ -196,7 +196,7 @@ Yap_LookupAtomWithAddress(char *atom, AtomEntry *ae)
|
|||||||
|
|
||||||
/* compute hash */
|
/* compute hash */
|
||||||
p = (unsigned char *)atom;
|
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 */
|
/* ask for a WRITE lock because it is highly unlikely we shall find anything */
|
||||||
WRITE_LOCK(HashChain[hash].AERWLock);
|
WRITE_LOCK(HashChain[hash].AERWLock);
|
||||||
a = HashChain[hash].Entry;
|
a = HashChain[hash].Entry;
|
||||||
@ -226,7 +226,7 @@ Yap_ReleaseAtom(Atom atom)
|
|||||||
|
|
||||||
/* compute hash */
|
/* compute hash */
|
||||||
p = (unsigned char *)name;
|
p = (unsigned char *)name;
|
||||||
HashFunction(p, hash);
|
hash = HashFunction(p) % MaxHash;
|
||||||
WRITE_LOCK(HashChain[hash].AERWLock);
|
WRITE_LOCK(HashChain[hash].AERWLock);
|
||||||
if (HashChain[hash].Entry == atom) {
|
if (HashChain[hash].Entry == atom) {
|
||||||
HashChain[hash].Entry = ap->NextOfAE;
|
HashChain[hash].Entry = ap->NextOfAE;
|
||||||
|
10
C/index.c
10
C/index.c
@ -4470,7 +4470,7 @@ kill_block(path_stack_entry *sp, PredEntry *ap)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static path_stack_entry *
|
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;
|
LogUpdIndex *blk;
|
||||||
yamop *start;
|
yamop *start;
|
||||||
@ -4498,11 +4498,11 @@ kill_clause(yamop *ipc, path_stack_entry *sp, PredEntry *ap)
|
|||||||
case _retry:
|
case _retry:
|
||||||
case _try_clause:
|
case _try_clause:
|
||||||
/* kill block and replace by this single 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;
|
path_stack_entry *nsp = sp;
|
||||||
|
|
||||||
while ((--nsp)->flag != block_entry);
|
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);
|
Yap_kill_iblock(sp->u.cle.block, nsp->u.cle.block, ap);
|
||||||
return sp;
|
return sp;
|
||||||
} else {
|
} else {
|
||||||
@ -5472,7 +5472,7 @@ remove_from_index(PredEntry *ap, path_stack_entry *sp, ClauseDef *cls, yamop *bg
|
|||||||
have to expand the index.
|
have to expand the index.
|
||||||
*/
|
*/
|
||||||
if (IN_BETWEEN(bg,ipc->u.ld.d,lt)) {
|
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);
|
ipc = pop_path(&sp, cls, ap);
|
||||||
} else {
|
} else {
|
||||||
/* just go to next instruction */
|
/* 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);
|
ipc = NEXTOP(ipc, ld);
|
||||||
case _trust:
|
case _trust:
|
||||||
if (IN_BETWEEN(bg,ipc->u.ld.d,lt)) {
|
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);
|
ipc = pop_path(&sp, cls, ap);
|
||||||
break;
|
break;
|
||||||
|
@ -121,10 +121,10 @@ Yap_LookupVar(char *var) /* lookup variable in variables table */
|
|||||||
if (var[0] != '_' || var[1] != '\0') {
|
if (var[0] != '_' || var[1] != '\0') {
|
||||||
VarEntry **op = &Yap_VarTable;
|
VarEntry **op = &Yap_VarTable;
|
||||||
unsigned char *vp = (unsigned char *)var;
|
unsigned char *vp = (unsigned char *)var;
|
||||||
CELL hv;
|
UInt hv;
|
||||||
|
|
||||||
p = Yap_VarTable;
|
p = Yap_VarTable;
|
||||||
HashFunction(vp, hv);
|
hv = HashFunction(vp) % MaxHash;
|
||||||
while (p != NULL) {
|
while (p != NULL) {
|
||||||
CELL hpv = p->hv;
|
CELL hpv = p->hv;
|
||||||
if (hv == hpv) {
|
if (hv == hpv) {
|
||||||
|
@ -323,7 +323,13 @@ extern int Yap_Portray_delays;
|
|||||||
#endif
|
#endif
|
||||||
#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 FAIL_ON_PARSER_ERROR 0
|
||||||
#define QUIET_ON_PARSER_ERROR 1
|
#define QUIET_ON_PARSER_ERROR 1
|
||||||
|
Reference in New Issue
Block a user