Browse Source

rtl-generics: speed up quadratic probe function. If the hash table size is a prime number and load factor is < 0.5 then the probe function p(k,i)=(h(k)+sqr(i)) is sufficient.

git-svn-id: trunk@35627 -
maciej-izak 8 years ago
parent
commit
dcf172dee4
1 changed files with 1 additions and 12 deletions
  1. 1 12
      packages/rtl-generics/src/generics.memoryexpanders.pas

+ 1 - 12
packages/rtl-generics/src/generics.memoryexpanders.pas

@@ -47,12 +47,7 @@ type
   { TQuadraticProbing }
 
   TQuadraticProbing = class(TProbeSequence)
-  private
-    class constructor Create;
   public
-    class var C1: UInt32;
-    class var C2: UInt32;
-
     class function Probe(I, Hash: UInt32): UInt32; static; inline;
 
     const MAX_LOAD_FACTOR = 0.5;
@@ -214,15 +209,9 @@ end;
 
 { TQuadraticProbing }
 
-class constructor TQuadraticProbing.Create;
-begin
-  C1 := 1;
-  C2 := 1;
-end;
-
 class function TQuadraticProbing.Probe(I, Hash: UInt32): UInt32;
 begin
-  Result := (Hash + C1 * I {%H-}+ C2 * Sqr(I));
+  Result := (Hash + Sqr(I));
 end;
 
 { TDoubleHashingNoMod }