Browse Source

Fixed a queue rebase function that allowed you to unqueue an item that didn't exist.

Henrique Gottardi Werlang 1 year ago
parent
commit
41fc39d1e9
1 changed files with 7 additions and 6 deletions
  1. 7 6
      packages/rtl/src/generics.collections.pas

+ 7 - 6
packages/rtl/src/generics.collections.pas

@@ -1907,15 +1907,16 @@ Var
   I,Spare : integer;
 
 begin
-  Spare:=Capacity-Count;
   if FLow>0 then
-    begin
-    For I:=Flow to FLength do
+  begin
+    For I:=Flow to Pred(FLength) do
       FItems[I-FLow]:=FItems[I];
-    SetLength(FItems,FLength+Spare);
-    FLength:=FLength-Flow+1;
+
+    FLength:=FLength-Flow;
     Flow:=0;
-    end;
+
+    SetLength(FItems, FLength);
+  end;
 end;
 
 procedure TQueue<T>.TrimExcess;