-
-
Notifications
You must be signed in to change notification settings - Fork 177
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ENHANCED: Simplify generating a joined key for multiple arguments.
- Loading branch information
1 parent
720359e
commit 7b25563
Showing
2 changed files
with
20 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,7 +3,7 @@ | |
Author: Jan Wielemaker | ||
E-mail: [email protected] | ||
WWW: http://www.swi-prolog.org | ||
Copyright (c) 1985-2024, University of Amsterdam | ||
Copyright (c) 1985-2025, University of Amsterdam | ||
VU University Amsterdam | ||
SWI-Prolog Solutions b.v. | ||
All rights reserved. | ||
|
@@ -392,20 +392,26 @@ setClauseChoice(DECL_LD ClauseChoice chp, ClauseRef cref, gen_t generation) | |
} | ||
|
||
|
||
static inline word | ||
join_multi_arg_keys(const word *key, unsigned int len) | ||
{ word k = MurmurHashAligned2(key, sizeof(word)*len, MURMUR_SEED); | ||
return clean_index_key(k); | ||
} | ||
|
||
static inline word | ||
indexKeyFromArgv(ClauseIndex ci, Word argv) | ||
{ if ( likely(ci->args[1] == 0) ) | ||
{ return indexOfWord(argv[ci->args[0]-1]); | ||
} else | ||
{ word key[MAX_MULTI_INDEX]; | ||
int harg; | ||
unsigned int harg; | ||
|
||
for(harg=0; ci->args[harg]; harg++) | ||
{ if ( !(key[harg] = indexOfWord(argv[ci->args[harg]-1])) ) | ||
return 0; | ||
} | ||
|
||
return murmur_key(key, sizeof(word)*harg); | ||
return join_multi_arg_keys(key, harg); | ||
} | ||
} | ||
|
||
|
@@ -1438,7 +1444,7 @@ indexKeyFromClause(ClauseIndex ci, Clause cl, Code *end) | |
return key; | ||
return 0; | ||
} else | ||
{ word key[MAX_MULTI_INDEX]; /* TBD: special case for 1 arg */ | ||
{ word key[MAX_MULTI_INDEX]; | ||
int pcarg = 1; | ||
int harg; | ||
|
||
|
@@ -1452,7 +1458,7 @@ indexKeyFromClause(ClauseIndex ci, Clause cl, Code *end) | |
return 0; | ||
} | ||
|
||
return murmur_key(key, sizeof(word)*harg); | ||
return join_multi_arg_keys(key, harg); | ||
} | ||
} | ||
|
||
|
@@ -2624,7 +2630,7 @@ assess_scan_clauses(ClauseList clist, iarg_t ac, | |
if ( isvar ) | ||
a->var_count++; | ||
else | ||
assessAddKey(a, murmur_key(key, sizeof(word)*harg), false); | ||
assessAddKey(a, join_multi_arg_keys(key, harg), false); | ||
} | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters