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