瀏覽代碼

The speed of TDictionary is now fixed

Alligator-1 3 月之前
父節點
當前提交
4b6d841cc0
共有 1 個文件被更改,包括 11 次插入11 次删除
  1. 11 11
      packages/rtl-generics/src/inc/generics.dictionaries.inc

+ 11 - 11
packages/rtl-generics/src/inc/generics.dictionaries.inc

@@ -800,7 +800,6 @@ end;
 function TOpenAddressingLP<OPEN_ADDRESSING_CONSTRAINTS>.FindBucketIndex(const AItems: TArray<TItem>;
 function TOpenAddressingLP<OPEN_ADDRESSING_CONSTRAINTS>.FindBucketIndex(const AItems: TArray<TItem>;
   const AKey: TKey; out AHash: UInt32): SizeInt;
   const AKey: TKey; out AHash: UInt32): SizeInt;
 var
 var
-  LItem: {TOpenAddressing<OPEN_ADDRESSING_CONSTRAINTS>.}_TItem; // for workaround Lazarus bug #25613
   LLengthMask: SizeInt;
   LLengthMask: SizeInt;
   i, m: SizeInt;
   i, m: SizeInt;
   LHash: UInt32;
   LHash: UInt32;
@@ -820,16 +819,17 @@ begin
   Result := LHash and LLengthMask;
   Result := LHash and LLengthMask;
 
 
   repeat
   repeat
-    LItem := _TItem(AItems[Result]);
-
-    // Empty position
-    if (LItem.Hash and UInt32.GetSignMask) = 0 then
-      Exit(not Result); // insert!
-
-    // Same position?
-    if LItem.Hash = LHash then
-      if FEqualityComparer.Equals(AKey, LItem.Pair.Key) then
-        Exit;
+    with AItems[Result] do
+    begin
+      // Empty position
+      if (Hash and UInt32.GetSignMask) = 0 then
+        Exit(not Result); // insert!
+
+      // Same position?
+      if Hash = LHash then
+        if FEqualityComparer.Equals(AKey, Pair.Key) then
+          Exit;
+    end;
 
 
     Inc(i);
     Inc(i);