mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-11-20 10:49:34 +01:00
* since T(Tag)HashSet always forces the size to a power of 2, use "and"
rather than "mod" to select the hash bucket git-svn-id: trunk@32055 -
This commit is contained in:
parent
9431648b6c
commit
231039b224
@ -2881,7 +2881,7 @@ end;
|
|||||||
h: LongWord;
|
h: LongWord;
|
||||||
begin
|
begin
|
||||||
h := FPHash(Key, KeyLen);
|
h := FPHash(Key, KeyLen);
|
||||||
Entry := @FBucket[h mod FBucketCount];
|
Entry := @FBucket[h and (FBucketCount-1)];
|
||||||
while Assigned(Entry^) and
|
while Assigned(Entry^) and
|
||||||
not ((Entry^^.HashValue = h) and (Entry^^.KeyLength = KeyLen) and
|
not ((Entry^^.HashValue = h) and (Entry^^.KeyLength = KeyLen) and
|
||||||
(CompareByte(Entry^^.Key^, Key^, KeyLen) = 0)) do
|
(CompareByte(Entry^^.Key^, Key^, KeyLen) = 0)) do
|
||||||
@ -2930,7 +2930,7 @@ end;
|
|||||||
e := FBucket[i];
|
e := FBucket[i];
|
||||||
while Assigned(e) do
|
while Assigned(e) do
|
||||||
begin
|
begin
|
||||||
chain := @p[e^.HashValue mod NewCapacity];
|
chain := @p[e^.HashValue and (NewCapacity-1)];
|
||||||
n := e^.Next;
|
n := e^.Next;
|
||||||
e^.Next := chain^;
|
e^.Next := chain^;
|
||||||
chain^ := e;
|
chain^ := e;
|
||||||
@ -2988,7 +2988,7 @@ end;
|
|||||||
h: LongWord;
|
h: LongWord;
|
||||||
begin
|
begin
|
||||||
h := FPHash(Key, KeyLen, Tag);
|
h := FPHash(Key, KeyLen, Tag);
|
||||||
Entry := @PPTagHashSetItem(FBucket)[h mod FBucketCount];
|
Entry := @PPTagHashSetItem(FBucket)[h and (FBucketCount-1)];
|
||||||
while Assigned(Entry^) and
|
while Assigned(Entry^) and
|
||||||
not ((Entry^^.HashValue = h) and (Entry^^.KeyLength = KeyLen) and
|
not ((Entry^^.HashValue = h) and (Entry^^.KeyLength = KeyLen) and
|
||||||
(Entry^^.Tag = Tag) and (CompareByte(Entry^^.Key^, Key^, KeyLen) = 0)) do
|
(Entry^^.Tag = Tag) and (CompareByte(Entry^^.Key^, Key^, KeyLen) = 0)) do
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user