Browse Source

rtl-generics: remove unused "m" parameter from "Probe" methods for memory expanders related to dictionaries.

git-svn-id: trunk@35609 -
maciej-izak 8 years ago
parent
commit
cc5027cd75

+ 6 - 6
packages/rtl-generics/src/generics.memoryexpanders.pas

@@ -38,7 +38,7 @@ type
 
   TLinearProbing = class(TProbeSequence)
   public
-    class function Probe(I, {%H-}M, Hash: UInt32): UInt32; static; inline;
+    class function Probe(I, Hash: UInt32): UInt32; static; inline;
 
     const MAX_LOAD_FACTOR = 1;
     const DEFAULT_LOAD_FACTOR = 0.75;
@@ -53,7 +53,7 @@ type
     class var C1: UInt32;
     class var C2: UInt32;
 
-    class function Probe(I, {%H-}M, Hash: UInt32): UInt32; static; inline;
+    class function Probe(I, Hash: UInt32): UInt32; static; inline;
 
     const MAX_LOAD_FACTOR = 0.5;
     const DEFAULT_LOAD_FACTOR = 0.5;
@@ -63,7 +63,7 @@ type
 
   TDoubleHashing = class(TProbeSequence)
   public
-    class function Probe(I, {%H-}M, Hash1: UInt32; Hash2: UInt32 = 1): UInt32; static; inline;
+    class function Probe(I, Hash1: UInt32; Hash2: UInt32 = 1): UInt32; static; inline;
 
     const MAX_LOAD_FACTOR = 1;
     const DEFAULT_LOAD_FACTOR = 0.85;
@@ -207,7 +207,7 @@ end;
 
 { TLinearProbing }
 
-class function TLinearProbing.Probe(I, M, Hash: UInt32): UInt32;
+class function TLinearProbing.Probe(I, Hash: UInt32): UInt32;
 begin
   Result := (Hash + I)
 end;
@@ -220,14 +220,14 @@ begin
   C2 := 1;
 end;
 
-class function TQuadraticProbing.Probe(I, M, Hash: UInt32): UInt32;
+class function TQuadraticProbing.Probe(I, Hash: UInt32): UInt32;
 begin
   Result := (Hash + C1 * I {%H-}+ C2 * Sqr(I));
 end;
 
 { TDoubleHashingNoMod }
 
-class function TDoubleHashing.Probe(I, M, Hash1: UInt32; Hash2: UInt32): UInt32;
+class function TDoubleHashing.Probe(I, Hash1: UInt32; Hash2: UInt32): UInt32;
 begin
   Result := Hash1 + I * Hash2;
 end;

+ 9 - 10
packages/rtl-generics/src/inc/generics.dictionaries.inc

@@ -574,7 +574,7 @@ var
   LItem: PItem;
   LPair: TPair<TKey, TValue>;
   LLengthMask: SizeInt;
-  i, m, LIndex, LGapIndex: SizeInt;
+  i, LIndex, LGapIndex: SizeInt;
   LHash, LBucket: UInt32;
 begin
   LItem := @FItems[AIndex];
@@ -583,12 +583,11 @@ begin
   // try fill gap
   LHash := LItem.Hash;
   LItem.Hash := 0; // prevents an infinite searching loop
-  m := Length(FItems);
-  LLengthMask := m - 1;
+  LLengthMask := Length(FItems) - 1;
   i := Succ(AIndex - (LHash and LLengthMask));
   LGapIndex := AIndex;
   repeat
-    LIndex := TProbeSequence.Probe(i, m, LHash) and LLengthMask;
+    LIndex := TProbeSequence.Probe(i, LHash) and LLengthMask;
     LItem := @FItems[LIndex];
 
     // Empty position
@@ -650,7 +649,7 @@ begin
 
     Inc(i);
 
-    Result := TProbeSequence.Probe(i, m, AHash) and LLengthMask;
+    Result := TProbeSequence.Probe(i, AHash) and LLengthMask;
 
   until false;
 end;
@@ -743,7 +742,7 @@ begin
 
     Inc(i);
 
-    Result := TProbeSequence.Probe(i, m, AHash) and LLengthMask;
+    Result := TProbeSequence.Probe(i, AHash) and LLengthMask;
 
   until false;
 end;
@@ -783,7 +782,7 @@ begin
 
     Inc(i);
 
-    Result := TProbeSequence.Probe(i, m, AHash) and LLengthMask;
+    Result := TProbeSequence.Probe(i, AHash) and LLengthMask;
 
   until false;
 end;
@@ -824,7 +823,7 @@ begin
 
   for i := 0 to FPrimaryNumberAsSizeApproximation - 1 do
   begin
-    Result := TProbeSequence.Probe(i, m, AHash) mod FPrimaryNumberAsSizeApproximation;
+    Result := TProbeSequence.Probe(i, AHash) mod FPrimaryNumberAsSizeApproximation;
     LItem := _TItem(AItems[Result]);
 
     // Empty position or tombstone
@@ -937,7 +936,7 @@ begin
 
     Inc(i);
 
-    Result := TProbeSequence.Probe(i, m, AHash, LHash2) and LLengthMask;
+    Result := TProbeSequence.Probe(i, AHash, LHash2) and LLengthMask;
   until false;
 end;
 
@@ -981,7 +980,7 @@ begin
 
     Inc(i);
 
-    Result := TProbeSequence.Probe(i, m, AHash, LHash2) and LLengthMask;
+    Result := TProbeSequence.Probe(i, AHash, LHash2) and LLengthMask;
   until false;
 end;