1
0
mirror of https://github.com/dschmenk/PLASMA.git synced 2024-10-18 07:24:16 +00:00

Slightly improve hash function

This commit is contained in:
David Schmenk 2024-01-01 14:36:49 -08:00
parent 3b8bad0abd
commit 8dd03a3413

View File

@ -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