2
0
Эх сурвалжийг харах

* TFPHashlist.Pack now also reclaims unused string memory

git-svn-id: trunk@23252 -
michael 12 жил өмнө
parent
commit
48c3adfdb9

+ 22 - 11
packages/fcl-base/src/contnrs.pp

@@ -1552,20 +1552,31 @@ var
   i : integer;
   pdest,
   psrc : PHashItem;
+  FOldStr : Pchar;
+
 begin
   NewCount:=0;
   psrc:=@FHashList^[0];
-  pdest:=psrc;
-  For I:=0 To FCount-1 Do
-    begin
-      if assigned(psrc^.Data) then
-        begin
-          pdest^:=psrc^;
-          inc(pdest);
-          inc(NewCount);
-        end;
-      inc(psrc);
-    end;
+  FOldStr:=FStrs;
+  try
+    FStrs:=Nil;
+    FStrCount:=0;
+    FStrCapacity:=0;
+    pdest:=psrc;
+    For I:=0 To FCount-1 Do
+      begin
+        if assigned(psrc^.Data) then
+          begin
+            pdest^:=psrc^;
+            Pdest^.strindex:=AddStr(PShortString(@FOldStr[PDest^.StrIndex])^);
+            inc(pdest);
+            inc(NewCount);
+          end;
+        inc(psrc);
+      end;
+  finally
+    FreeMem(FoldStr);
+  end;
   FCount:=NewCount;
   { We need to ReHash to update the IndexNext }
   ReHash;