mirror of
https://github.com/dschmenk/PLASMA.git
synced 2025-01-07 15:31:49 +00:00
Slightly improve hash function
This commit is contained in:
parent
3b8bad0abd
commit
8dd03a3413
@ -683,7 +683,7 @@ def hashname(chars, len)#1
|
||||
|
||||
hash = 0
|
||||
while len
|
||||
hash = hash + ^chars
|
||||
hash = (hash << 1) ^ ^chars
|
||||
chars++
|
||||
len--
|
||||
loop
|
||||
@ -713,19 +713,18 @@ def buildhashtbl#0
|
||||
end
|
||||
def find(matchchars, matchlen)#1
|
||||
word dentry
|
||||
byte i, hash
|
||||
byte i
|
||||
|
||||
hash = hashname(matchchars, matchlen)
|
||||
dentry = hashtbl[hashname(matchchars, matchlen)]
|
||||
matchchars--
|
||||
dentry = hashtbl[hash]
|
||||
while dentry
|
||||
if ^dentry == matchlen
|
||||
for i = 1 to ^dentry
|
||||
for i = matchlen downto 1
|
||||
if ^(matchchars + i) <> ^(dentry + i)
|
||||
break
|
||||
fin
|
||||
next
|
||||
if i > ^dentry
|
||||
if i == 0
|
||||
return dentry
|
||||
fin
|
||||
fin
|
||||
@ -813,7 +812,6 @@ end
|
||||
// Execute code in CFA
|
||||
//
|
||||
def execword(dentry)#0
|
||||
|
||||
when conio:keypressed()
|
||||
is $83 // CTRL-C
|
||||
getc // Clear KB
|
||||
|
Loading…
Reference in New Issue
Block a user