imprive speed of ql
This commit is contained in:
parent
81743361a6
commit
1be424fe57
10
C/qlyr.c
10
C/qlyr.c
@ -379,7 +379,7 @@ CloseHash(void)
|
|||||||
import_dbref_hash_entry_t *a0 = a;
|
import_dbref_hash_entry_t *a0 = a;
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
if (!a->count) {
|
if (!a->count) {
|
||||||
fprintf(stderr,"WARNING: unused reference %p\n",a);
|
fprintf(stderr,"WARNING: unused reference %p %p\n",a->val, a->oval);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
a = a->next;
|
a = a->next;
|
||||||
@ -687,7 +687,7 @@ ReadHash(IOSTREAM *stream)
|
|||||||
RCHECK(read_tag(stream) == QLY_START_ATOMS);
|
RCHECK(read_tag(stream) == QLY_START_ATOMS);
|
||||||
LOCAL_ImportAtomHashTableNum = read_uint(stream);
|
LOCAL_ImportAtomHashTableNum = read_uint(stream);
|
||||||
LOCAL_ImportAtomHashTableSize = LOCAL_ImportAtomHashTableNum*2;
|
LOCAL_ImportAtomHashTableSize = LOCAL_ImportAtomHashTableNum*2;
|
||||||
LOCAL_ImportAtomHashChain = (import_atom_hash_entry_t **)calloc(1, sizeof(import_atom_hash_entry_t *)* LOCAL_ImportAtomHashTableSize);
|
LOCAL_ImportAtomHashChain = (import_atom_hash_entry_t **)calloc(LOCAL_ImportAtomHashTableSize, sizeof(import_atom_hash_entry_t *));
|
||||||
for (i = 0; i < LOCAL_ImportAtomHashTableNum; i++) {
|
for (i = 0; i < LOCAL_ImportAtomHashTableNum; i++) {
|
||||||
Atom oat = (Atom)read_uint(stream);
|
Atom oat = (Atom)read_uint(stream);
|
||||||
Atom at;
|
Atom at;
|
||||||
@ -729,7 +729,7 @@ ReadHash(IOSTREAM *stream)
|
|||||||
RCHECK(read_tag(stream) == QLY_START_FUNCTORS);
|
RCHECK(read_tag(stream) == QLY_START_FUNCTORS);
|
||||||
LOCAL_ImportFunctorHashTableNum = read_uint(stream);
|
LOCAL_ImportFunctorHashTableNum = read_uint(stream);
|
||||||
LOCAL_ImportFunctorHashTableSize = 2*LOCAL_ImportFunctorHashTableNum;
|
LOCAL_ImportFunctorHashTableSize = 2*LOCAL_ImportFunctorHashTableNum;
|
||||||
LOCAL_ImportFunctorHashChain = (import_functor_hash_entry_t **)calloc(1, sizeof(import_functor_hash_entry_t *)* LOCAL_ImportFunctorHashTableSize);
|
LOCAL_ImportFunctorHashChain = (import_functor_hash_entry_t **)calloc(LOCAL_ImportFunctorHashTableSize, sizeof(import_functor_hash_entry_t *));
|
||||||
for (i = 0; i < LOCAL_ImportFunctorHashTableNum; i++) {
|
for (i = 0; i < LOCAL_ImportFunctorHashTableNum; i++) {
|
||||||
Functor of = (Functor)read_uint(stream);
|
Functor of = (Functor)read_uint(stream);
|
||||||
UInt arity = read_uint(stream);
|
UInt arity = read_uint(stream);
|
||||||
@ -746,7 +746,7 @@ ReadHash(IOSTREAM *stream)
|
|||||||
RCHECK(read_tag(stream) == QLY_START_PRED_ENTRIES);
|
RCHECK(read_tag(stream) == QLY_START_PRED_ENTRIES);
|
||||||
LOCAL_ImportPredEntryHashTableNum = read_uint(stream);
|
LOCAL_ImportPredEntryHashTableNum = read_uint(stream);
|
||||||
LOCAL_ImportPredEntryHashTableSize = 2*LOCAL_ImportPredEntryHashTableNum;
|
LOCAL_ImportPredEntryHashTableSize = 2*LOCAL_ImportPredEntryHashTableNum;
|
||||||
LOCAL_ImportPredEntryHashChain = (import_pred_entry_hash_entry_t **)calloc(1, sizeof(import_pred_entry_hash_entry_t *)* LOCAL_ImportPredEntryHashTableSize);
|
LOCAL_ImportPredEntryHashChain = (import_pred_entry_hash_entry_t **)calloc( LOCAL_ImportPredEntryHashTableSize, sizeof(import_pred_entry_hash_entry_t *));
|
||||||
for (i = 0; i < LOCAL_ImportPredEntryHashTableNum; i++) {
|
for (i = 0; i < LOCAL_ImportPredEntryHashTableNum; i++) {
|
||||||
PredEntry *ope = (PredEntry *)read_uint(stream), *pe;
|
PredEntry *ope = (PredEntry *)read_uint(stream), *pe;
|
||||||
UInt arity = read_uint(stream);
|
UInt arity = read_uint(stream);
|
||||||
@ -794,7 +794,7 @@ ReadHash(IOSTREAM *stream)
|
|||||||
RCHECK(read_tag(stream) == QLY_START_DBREFS);
|
RCHECK(read_tag(stream) == QLY_START_DBREFS);
|
||||||
LOCAL_ImportDBRefHashTableNum = read_uint(stream);
|
LOCAL_ImportDBRefHashTableNum = read_uint(stream);
|
||||||
LOCAL_ImportDBRefHashTableSize = 2*LOCAL_ImportDBRefHashTableNum;
|
LOCAL_ImportDBRefHashTableSize = 2*LOCAL_ImportDBRefHashTableNum;
|
||||||
LOCAL_ImportDBRefHashChain = (import_dbref_hash_entry_t **)calloc(1, sizeof(import_dbref_hash_entry_t *)* LOCAL_ImportDBRefHashTableSize);
|
LOCAL_ImportDBRefHashChain = (import_dbref_hash_entry_t **)calloc(LOCAL_ImportDBRefHashTableSize, sizeof(import_dbref_hash_entry_t *));
|
||||||
for (i = 0; i < LOCAL_ImportDBRefHashTableNum; i++) {
|
for (i = 0; i < LOCAL_ImportDBRefHashTableNum; i++) {
|
||||||
LogUpdClause *ocl = (LogUpdClause *)read_uint(stream);
|
LogUpdClause *ocl = (LogUpdClause *)read_uint(stream);
|
||||||
UInt sz = read_uint(stream);
|
UInt sz = read_uint(stream);
|
||||||
|
216
C/qlyw.c
216
C/qlyw.c
@ -32,6 +32,42 @@
|
|||||||
STATIC_PROTO(void RestoreEntries, (PropEntry *, int USES_REGS));
|
STATIC_PROTO(void RestoreEntries, (PropEntry *, int USES_REGS));
|
||||||
STATIC_PROTO(void CleanCode, (PredEntry * USES_REGS));
|
STATIC_PROTO(void CleanCode, (PredEntry * USES_REGS));
|
||||||
|
|
||||||
|
static void
|
||||||
|
GrowAtomTable(void) {
|
||||||
|
CACHE_REGS
|
||||||
|
UInt size = LOCAL_ExportAtomHashTableSize;
|
||||||
|
export_atom_hash_entry_t *p, *newt, *oldt = LOCAL_ExportAtomHashChain;
|
||||||
|
UInt new_size = size + (size > 1024 ? size : 1024);
|
||||||
|
UInt i;
|
||||||
|
|
||||||
|
newt = (export_atom_hash_entry_t *)calloc(new_size,sizeof(export_atom_hash_entry_t));
|
||||||
|
if (!newt) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
p = oldt;
|
||||||
|
for (i = 0 ; i < size ; p++,i++) {
|
||||||
|
Atom a = p->val;
|
||||||
|
export_atom_hash_entry_t *newp;
|
||||||
|
CELL hash;
|
||||||
|
char *apt;
|
||||||
|
|
||||||
|
|
||||||
|
if (!a) continue;
|
||||||
|
apt = RepAtom(a)->StrOfAE;
|
||||||
|
hash = HashFunction((unsigned char *)apt)/(2*sizeof(CELL)) % new_size;
|
||||||
|
newp = newt+hash;
|
||||||
|
while (newp->val) {
|
||||||
|
newp++;
|
||||||
|
if (newp == newt+new_size)
|
||||||
|
newp = newt;
|
||||||
|
}
|
||||||
|
newp->val = a;
|
||||||
|
}
|
||||||
|
LOCAL_ExportAtomHashChain = newt;
|
||||||
|
LOCAL_ExportAtomHashTableSize = new_size;
|
||||||
|
free(oldt);
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
LookupAtom(Atom at)
|
LookupAtom(Atom at)
|
||||||
{
|
{
|
||||||
@ -40,54 +76,99 @@ LookupAtom(Atom at)
|
|||||||
CELL hash = HashFunction((unsigned char *)p) % LOCAL_ExportAtomHashTableSize;
|
CELL hash = HashFunction((unsigned char *)p) % LOCAL_ExportAtomHashTableSize;
|
||||||
export_atom_hash_entry_t *a;
|
export_atom_hash_entry_t *a;
|
||||||
|
|
||||||
a = LOCAL_ExportAtomHashChain[hash];
|
a = LOCAL_ExportAtomHashChain+hash;
|
||||||
while (a) {
|
while (a->val) {
|
||||||
if (a->val == at) {
|
if (a->val == at) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
a = a->next;
|
a++;
|
||||||
}
|
if (a == LOCAL_ExportAtomHashChain+LOCAL_ExportAtomHashTableSize)
|
||||||
a = (export_atom_hash_entry_t *)malloc(sizeof(export_atom_hash_entry_t));
|
a = LOCAL_ExportAtomHashChain;
|
||||||
if (!a) {
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
a->val = at;
|
a->val = at;
|
||||||
a->next = LOCAL_ExportAtomHashChain[hash];
|
|
||||||
LOCAL_ExportAtomHashChain[hash] = a;
|
|
||||||
LOCAL_ExportAtomHashTableNum++;
|
LOCAL_ExportAtomHashTableNum++;
|
||||||
|
if (LOCAL_ExportAtomHashTableNum >
|
||||||
|
LOCAL_ExportAtomHashTableSize/2
|
||||||
|
) {
|
||||||
|
GrowAtomTable();
|
||||||
|
if (!LOCAL_ExportAtomHashChain) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
GrowFunctorTable(void) {
|
||||||
|
CACHE_REGS
|
||||||
|
UInt size = LOCAL_ExportFunctorHashTableSize;
|
||||||
|
export_functor_hash_entry_t *p, *newt, *oldt = LOCAL_ExportFunctorHashChain;
|
||||||
|
UInt new_size = size + (size > 1024 ? size : 1024);
|
||||||
|
UInt i;
|
||||||
|
|
||||||
|
newt = (export_functor_hash_entry_t *)calloc(new_size,sizeof(export_functor_hash_entry_t));
|
||||||
|
if (!newt) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
p = oldt;
|
||||||
|
for (i = 0 ; i < size ; p++,i++) {
|
||||||
|
Functor f = p->val;
|
||||||
|
export_functor_hash_entry_t *newp;
|
||||||
|
CELL hash;
|
||||||
|
|
||||||
|
if (!f) continue;
|
||||||
|
hash = ((CELL)(f))/(2*sizeof(CELL)) % new_size;
|
||||||
|
newp = newt+hash;
|
||||||
|
while (newp->val) {
|
||||||
|
newp++;
|
||||||
|
if (newp == newt+new_size)
|
||||||
|
newp = newt;
|
||||||
|
}
|
||||||
|
newp->val = p->val;
|
||||||
|
newp->arity = p->arity;
|
||||||
|
newp->name = p->name;
|
||||||
|
}
|
||||||
|
LOCAL_ExportFunctorHashChain = newt;
|
||||||
|
LOCAL_ExportFunctorHashTableSize = new_size;
|
||||||
|
free(oldt);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
LookupFunctor(Functor fun)
|
LookupFunctor(Functor fun)
|
||||||
{
|
{
|
||||||
CACHE_REGS
|
CACHE_REGS
|
||||||
CELL hash = (CELL)(fun) % LOCAL_ExportFunctorHashTableSize;
|
CELL hash = ((CELL)(fun))/(2*sizeof(CELL)) % LOCAL_ExportFunctorHashTableSize;
|
||||||
export_functor_hash_entry_t *f;
|
export_functor_hash_entry_t *f;
|
||||||
Atom name = NameOfFunctor(fun);
|
Atom name = NameOfFunctor(fun);
|
||||||
UInt arity = ArityOfFunctor(fun);
|
UInt arity = ArityOfFunctor(fun);
|
||||||
|
|
||||||
f = LOCAL_ExportFunctorHashChain[hash];
|
f = LOCAL_ExportFunctorHashChain+hash;
|
||||||
while (f) {
|
while (f->val) {
|
||||||
if (f->name == name && f->arity == arity) {
|
if (f->val == fun) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
f = f->next;
|
f++;
|
||||||
}
|
if (f == LOCAL_ExportFunctorHashChain+LOCAL_ExportFunctorHashTableSize)
|
||||||
f = (export_functor_hash_entry_t *)malloc(sizeof(export_functor_hash_entry_t));
|
f = LOCAL_ExportFunctorHashChain;
|
||||||
if (!f) {
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
LookupAtom(name);
|
LookupAtom(name);
|
||||||
f->val = fun;
|
f->val = fun;
|
||||||
f->name = name;
|
f->name = name;
|
||||||
f->arity = arity;
|
f->arity = arity;
|
||||||
f->next = LOCAL_ExportFunctorHashChain[hash];
|
|
||||||
LOCAL_ExportFunctorHashChain[hash] = f;
|
|
||||||
LOCAL_ExportFunctorHashTableNum++;
|
LOCAL_ExportFunctorHashTableNum++;
|
||||||
|
if (LOCAL_ExportFunctorHashTableNum >
|
||||||
|
LOCAL_ExportFunctorHashTableSize/2
|
||||||
|
) {
|
||||||
|
GrowFunctorTable();
|
||||||
|
if (!LOCAL_ExportFunctorHashChain) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
GrowPredTable(void) {
|
GrowPredTable(void) {
|
||||||
|
CACHE_REGS
|
||||||
UInt size = LOCAL_ExportPredEntryHashTableSize;
|
UInt size = LOCAL_ExportPredEntryHashTableSize;
|
||||||
export_pred_entry_hash_entry_t *p, *newt, *oldt = LOCAL_ExportPredEntryHashChain;
|
export_pred_entry_hash_entry_t *p, *newt, *oldt = LOCAL_ExportPredEntryHashChain;
|
||||||
UInt new_size = size + (size > 1024 ? size : 1024);
|
UInt new_size = size + (size > 1024 ? size : 1024);
|
||||||
@ -178,31 +259,71 @@ LookupPredEntry(PredEntry *pe)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void
|
||||||
|
GrowDBRefTable(void) {
|
||||||
|
CACHE_REGS
|
||||||
|
UInt size = LOCAL_ExportDBRefHashTableSize;
|
||||||
|
export_dbref_hash_entry_t *p, *newt, *oldt = LOCAL_ExportDBRefHashChain;
|
||||||
|
UInt new_size = size + (size > 1024 ? size : 1024);
|
||||||
|
UInt i;
|
||||||
|
|
||||||
|
newt = (export_dbref_hash_entry_t *)calloc(new_size,sizeof(export_dbref_hash_entry_t));
|
||||||
|
if (!newt) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
p = oldt;
|
||||||
|
for (i = 0 ; i < size ; p++,i++) {
|
||||||
|
DBRef dbr = p->val;
|
||||||
|
export_dbref_hash_entry_t *newp;
|
||||||
|
CELL hash;
|
||||||
|
|
||||||
|
if (!dbr) continue;
|
||||||
|
hash = ((CELL)(dbr))/(2*sizeof(CELL)) % new_size;
|
||||||
|
newp = newt+hash;
|
||||||
|
while (newp->val) {
|
||||||
|
newp++;
|
||||||
|
if (newp == newt+new_size)
|
||||||
|
newp = newt;
|
||||||
|
}
|
||||||
|
newp->val = p->val;
|
||||||
|
newp->sz = p->sz;
|
||||||
|
newp->refs = p->refs;
|
||||||
|
}
|
||||||
|
LOCAL_ExportDBRefHashChain = newt;
|
||||||
|
LOCAL_ExportDBRefHashTableSize = new_size;
|
||||||
|
free(oldt);
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
LookupDBRef(DBRef ref)
|
LookupDBRef(DBRef ref)
|
||||||
{
|
{
|
||||||
CACHE_REGS
|
CACHE_REGS
|
||||||
CELL hash = Unsigned(ref) % LOCAL_ExportDBRefHashTableSize;
|
CELL hash = ((CELL)(ref))/(2*sizeof(CELL)) % LOCAL_ExportDBRefHashTableSize;
|
||||||
export_dbref_hash_entry_t *a;
|
export_dbref_hash_entry_t *a;
|
||||||
|
|
||||||
a = LOCAL_ExportDBRefHashChain[hash];
|
a = LOCAL_ExportDBRefHashChain+hash;
|
||||||
while (a) {
|
while (a->val) {
|
||||||
if (a->val == ref) {
|
if (a->val == ref) {
|
||||||
a->refs++;
|
a->refs++;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
a = a->next;
|
a++;
|
||||||
}
|
if (a == LOCAL_ExportDBRefHashChain+LOCAL_ExportDBRefHashTableSize)
|
||||||
a = (export_dbref_hash_entry_t *)malloc(sizeof(export_dbref_hash_entry_t));
|
a = LOCAL_ExportDBRefHashChain;
|
||||||
if (!a) {
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
a->val = ref;
|
a->val = ref;
|
||||||
a->sz = ((LogUpdClause *)ref)->ClSize;
|
a->sz = ((LogUpdClause *)ref)->ClSize;
|
||||||
a->refs = 1;
|
a->refs = 1;
|
||||||
a->next = LOCAL_ExportDBRefHashChain[hash];
|
|
||||||
LOCAL_ExportDBRefHashChain[hash] = a;
|
|
||||||
LOCAL_ExportDBRefHashTableNum++;
|
LOCAL_ExportDBRefHashTableNum++;
|
||||||
|
if (LOCAL_ExportDBRefHashTableNum >
|
||||||
|
LOCAL_ExportDBRefHashTableSize/2
|
||||||
|
) {
|
||||||
|
GrowDBRefTable();
|
||||||
|
if (!LOCAL_ExportDBRefHashChain) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -211,16 +332,16 @@ InitHash(void)
|
|||||||
CACHE_REGS
|
CACHE_REGS
|
||||||
LOCAL_ExportFunctorHashTableNum = 0;
|
LOCAL_ExportFunctorHashTableNum = 0;
|
||||||
LOCAL_ExportFunctorHashTableSize = EXPORT_FUNCTOR_TABLE_SIZE;
|
LOCAL_ExportFunctorHashTableSize = EXPORT_FUNCTOR_TABLE_SIZE;
|
||||||
LOCAL_ExportFunctorHashChain = (export_functor_hash_entry_t **)calloc(1, sizeof(export_functor_hash_entry_t *)* LOCAL_ExportFunctorHashTableSize);
|
LOCAL_ExportFunctorHashChain = (export_functor_hash_entry_t *)calloc(LOCAL_ExportFunctorHashTableSize, sizeof(export_functor_hash_entry_t ));
|
||||||
LOCAL_ExportAtomHashTableNum = 0;
|
LOCAL_ExportAtomHashTableNum = 0;
|
||||||
LOCAL_ExportAtomHashTableSize = EXPORT_ATOM_TABLE_SIZE;
|
LOCAL_ExportAtomHashTableSize = EXPORT_ATOM_TABLE_SIZE;
|
||||||
LOCAL_ExportAtomHashChain = (export_atom_hash_entry_t **)calloc(1, sizeof(export_atom_hash_entry_t *)* LOCAL_ExportAtomHashTableSize);
|
LOCAL_ExportAtomHashChain = (export_atom_hash_entry_t *)calloc( LOCAL_ExportAtomHashTableSize, sizeof(export_atom_hash_entry_t *));
|
||||||
LOCAL_ExportPredEntryHashTableNum = 0;
|
LOCAL_ExportPredEntryHashTableNum = 0;
|
||||||
LOCAL_ExportPredEntryHashTableSize = EXPORT_PRED_ENTRY_TABLE_SIZE;
|
LOCAL_ExportPredEntryHashTableSize = EXPORT_PRED_ENTRY_TABLE_SIZE;
|
||||||
LOCAL_ExportPredEntryHashChain = (export_pred_entry_hash_entry_t *)calloc(LOCAL_ExportPredEntryHashTableSize, sizeof(export_pred_entry_hash_entry_t));
|
LOCAL_ExportPredEntryHashChain = (export_pred_entry_hash_entry_t *)calloc(LOCAL_ExportPredEntryHashTableSize, sizeof(export_pred_entry_hash_entry_t));
|
||||||
LOCAL_ExportDBRefHashTableNum = 0;
|
LOCAL_ExportDBRefHashTableNum = 0;
|
||||||
LOCAL_ExportDBRefHashTableSize = EXPORT_DBREF_TABLE_SIZE;
|
LOCAL_ExportDBRefHashTableSize = EXPORT_DBREF_TABLE_SIZE;
|
||||||
LOCAL_ExportDBRefHashChain = (export_dbref_hash_entry_t **)calloc(1, sizeof(export_dbref_hash_entry_t *)* LOCAL_ExportDBRefHashTableSize);
|
LOCAL_ExportDBRefHashChain = (export_dbref_hash_entry_t *)calloc(EXPORT_DBREF_TABLE_SIZE, sizeof(export_dbref_hash_entry_t));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -449,9 +570,8 @@ SaveHash(IOSTREAM *stream)
|
|||||||
CHECK(save_tag(stream, QLY_START_ATOMS));
|
CHECK(save_tag(stream, QLY_START_ATOMS));
|
||||||
CHECK(save_uint(stream, LOCAL_ExportAtomHashTableNum));
|
CHECK(save_uint(stream, LOCAL_ExportAtomHashTableNum));
|
||||||
for (i = 0; i < LOCAL_ExportAtomHashTableSize; i++) {
|
for (i = 0; i < LOCAL_ExportAtomHashTableSize; i++) {
|
||||||
export_atom_hash_entry_t *a = LOCAL_ExportAtomHashChain[i];
|
export_atom_hash_entry_t *a = LOCAL_ExportAtomHashChain+i;
|
||||||
while (a) {
|
if (a->val) {
|
||||||
export_atom_hash_entry_t *a0 = a;
|
|
||||||
Atom at = a->val;
|
Atom at = a->val;
|
||||||
CHECK(save_uint(stream, (UInt)at));
|
CHECK(save_uint(stream, (UInt)at));
|
||||||
if (IsWideAtom(at)) {
|
if (IsWideAtom(at)) {
|
||||||
@ -463,22 +583,17 @@ SaveHash(IOSTREAM *stream)
|
|||||||
CHECK(save_uint(stream, strlen(RepAtom(at)->StrOfAE)));
|
CHECK(save_uint(stream, strlen(RepAtom(at)->StrOfAE)));
|
||||||
CHECK(save_bytes(stream, at->StrOfAE, (strlen(at->StrOfAE)+1)*sizeof(char)));
|
CHECK(save_bytes(stream, at->StrOfAE, (strlen(at->StrOfAE)+1)*sizeof(char)));
|
||||||
}
|
}
|
||||||
a = a->next;
|
|
||||||
free(a0);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
save_tag(stream, QLY_START_FUNCTORS);
|
save_tag(stream, QLY_START_FUNCTORS);
|
||||||
save_uint(stream, LOCAL_ExportFunctorHashTableNum);
|
save_uint(stream, LOCAL_ExportFunctorHashTableNum);
|
||||||
for (i = 0; i < LOCAL_ExportFunctorHashTableSize; i++) {
|
for (i = 0; i < LOCAL_ExportFunctorHashTableSize; i++) {
|
||||||
export_functor_hash_entry_t *f = LOCAL_ExportFunctorHashChain[i];
|
export_functor_hash_entry_t *f = LOCAL_ExportFunctorHashChain+i;
|
||||||
while (f) {
|
if (!(f->val))
|
||||||
export_functor_hash_entry_t *f0 = f;
|
continue;
|
||||||
CHECK(save_uint(stream, (UInt)(f->val)));
|
CHECK(save_uint(stream, (UInt)(f->val)));
|
||||||
CHECK(save_uint(stream, f->arity));
|
CHECK(save_uint(stream, f->arity));
|
||||||
CHECK(save_uint(stream, (CELL)(f->name)));
|
CHECK(save_uint(stream, (CELL)(f->name)));
|
||||||
f = f->next;
|
|
||||||
free(f0);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
save_tag(stream, QLY_START_PRED_ENTRIES);
|
save_tag(stream, QLY_START_PRED_ENTRIES);
|
||||||
save_uint(stream, LOCAL_ExportPredEntryHashTableNum);
|
save_uint(stream, LOCAL_ExportPredEntryHashTableNum);
|
||||||
@ -494,14 +609,11 @@ SaveHash(IOSTREAM *stream)
|
|||||||
save_tag(stream, QLY_START_DBREFS);
|
save_tag(stream, QLY_START_DBREFS);
|
||||||
save_uint(stream, LOCAL_ExportDBRefHashTableNum);
|
save_uint(stream, LOCAL_ExportDBRefHashTableNum);
|
||||||
for (i = 0; i < LOCAL_ExportDBRefHashTableSize; i++) {
|
for (i = 0; i < LOCAL_ExportDBRefHashTableSize; i++) {
|
||||||
export_dbref_hash_entry_t *p = LOCAL_ExportDBRefHashChain[i];
|
export_dbref_hash_entry_t *p = LOCAL_ExportDBRefHashChain+i;
|
||||||
while (p) {
|
if (p->val) {
|
||||||
export_dbref_hash_entry_t *p0 = p;
|
|
||||||
CHECK(save_uint(stream, (UInt)(p->val)));
|
CHECK(save_uint(stream, (UInt)(p->val)));
|
||||||
CHECK(save_uint(stream, p->sz));
|
CHECK(save_uint(stream, p->sz));
|
||||||
CHECK(save_uint(stream, p->refs));
|
CHECK(save_uint(stream, p->refs));
|
||||||
p = p->next;
|
|
||||||
free(p0);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
save_tag(stream, QLY_FAILCODE);
|
save_tag(stream, QLY_FAILCODE);
|
||||||
|
@ -196,16 +196,16 @@ typedef struct worker_local {
|
|||||||
int do_trace_primitives_;
|
int do_trace_primitives_;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
struct export_atom_hash_entry_struct **ExportAtomHashChain_;
|
struct export_atom_hash_entry_struct *ExportAtomHashChain_;
|
||||||
UInt ExportAtomHashTableSize_;
|
UInt ExportAtomHashTableSize_;
|
||||||
UInt ExportAtomHashTableNum_;
|
UInt ExportAtomHashTableNum_;
|
||||||
struct export_functor_hash_entry_struct **ExportFunctorHashChain_;
|
struct export_functor_hash_entry_struct *ExportFunctorHashChain_;
|
||||||
UInt ExportFunctorHashTableSize_;
|
UInt ExportFunctorHashTableSize_;
|
||||||
UInt ExportFunctorHashTableNum_;
|
UInt ExportFunctorHashTableNum_;
|
||||||
struct export_pred_entry_hash_entry_struct *ExportPredEntryHashChain_;
|
struct export_pred_entry_hash_entry_struct *ExportPredEntryHashChain_;
|
||||||
UInt ExportPredEntryHashTableSize_;
|
UInt ExportPredEntryHashTableSize_;
|
||||||
UInt ExportPredEntryHashTableNum_;
|
UInt ExportPredEntryHashTableNum_;
|
||||||
struct export_dbref_hash_entry_struct **ExportDBRefHashChain_;
|
struct export_dbref_hash_entry_struct *ExportDBRefHashChain_;
|
||||||
UInt ExportDBRefHashTableSize_;
|
UInt ExportDBRefHashTableSize_;
|
||||||
UInt ExportDBRefHashTableNum_;
|
UInt ExportDBRefHashTableNum_;
|
||||||
struct import_atom_hash_entry_struct **ImportAtomHashChain_;
|
struct import_atom_hash_entry_struct **ImportAtomHashChain_;
|
||||||
|
3
H/qly.h
3
H/qly.h
@ -24,7 +24,6 @@
|
|||||||
|
|
||||||
typedef struct export_atom_hash_entry_struct {
|
typedef struct export_atom_hash_entry_struct {
|
||||||
Atom val;
|
Atom val;
|
||||||
struct export_atom_hash_entry_struct *next;
|
|
||||||
} export_atom_hash_entry_t;
|
} export_atom_hash_entry_t;
|
||||||
|
|
||||||
typedef struct import_atom_hash_entry_struct {
|
typedef struct import_atom_hash_entry_struct {
|
||||||
@ -37,7 +36,6 @@ typedef struct export_functor_hash_entry_struct {
|
|||||||
Functor val;
|
Functor val;
|
||||||
Atom name;
|
Atom name;
|
||||||
UInt arity;
|
UInt arity;
|
||||||
struct export_functor_hash_entry_struct *next;
|
|
||||||
} export_functor_hash_entry_t;
|
} export_functor_hash_entry_t;
|
||||||
|
|
||||||
typedef struct import_functor_hash_entry_struct {
|
typedef struct import_functor_hash_entry_struct {
|
||||||
@ -73,7 +71,6 @@ typedef struct export_dbref_hash_entry_struct {
|
|||||||
DBRef val;
|
DBRef val;
|
||||||
UInt sz;
|
UInt sz;
|
||||||
UInt refs;
|
UInt refs;
|
||||||
struct export_dbref_hash_entry_struct *next;
|
|
||||||
} export_dbref_hash_entry_t;
|
} export_dbref_hash_entry_t;
|
||||||
|
|
||||||
typedef struct import_dbref_hash_entry_struct {
|
typedef struct import_dbref_hash_entry_struct {
|
||||||
|
@ -223,16 +223,16 @@ int do_trace_primitives =TRUE
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
//quick loader
|
//quick loader
|
||||||
struct export_atom_hash_entry_struct **ExportAtomHashChain =NULL
|
struct export_atom_hash_entry_struct *ExportAtomHashChain =NULL
|
||||||
UInt ExportAtomHashTableSize =0
|
UInt ExportAtomHashTableSize =0
|
||||||
UInt ExportAtomHashTableNum =0
|
UInt ExportAtomHashTableNum =0
|
||||||
struct export_functor_hash_entry_struct **ExportFunctorHashChain =NULL
|
struct export_functor_hash_entry_struct *ExportFunctorHashChain =NULL
|
||||||
UInt ExportFunctorHashTableSize =0
|
UInt ExportFunctorHashTableSize =0
|
||||||
UInt ExportFunctorHashTableNum =0
|
UInt ExportFunctorHashTableNum =0
|
||||||
struct export_pred_entry_hash_entry_struct *ExportPredEntryHashChain =NULL
|
struct export_pred_entry_hash_entry_struct *ExportPredEntryHashChain =NULL
|
||||||
UInt ExportPredEntryHashTableSize =0
|
UInt ExportPredEntryHashTableSize =0
|
||||||
UInt ExportPredEntryHashTableNum =0
|
UInt ExportPredEntryHashTableNum =0
|
||||||
struct export_dbref_hash_entry_struct **ExportDBRefHashChain =NULL
|
struct export_dbref_hash_entry_struct *ExportDBRefHashChain =NULL
|
||||||
UInt ExportDBRefHashTableSize =0
|
UInt ExportDBRefHashTableSize =0
|
||||||
UInt ExportDBRefHashTableNum =0
|
UInt ExportDBRefHashTableNum =0
|
||||||
struct import_atom_hash_entry_struct **ImportAtomHashChain =NULL
|
struct import_atom_hash_entry_struct **ImportAtomHashChain =NULL
|
||||||
|
Reference in New Issue
Block a user