Pārlūkot izejas kodu

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

Jonas Maebe 9 gadi atpakaļ
vecāks
revīzija
231039b224
1 mainītis faili ar 3 papildinājumiem un 3 dzēšanām
  1. 3 3
      compiler/cclasses.pas

+ 3 - 3
compiler/cclasses.pas

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