View Issue Details

IDProjectCategoryView StatusLast Update
0030875FPCRTLpublic2016-11-09 22:29
ReporterAlexey Tor.Assigned ToMichael Van Canneyt 
PrioritynormalSeverityminorReproducibilityN/A
Status resolvedResolutionfixed 
Product Version3.1.1Product Build 
Target Version3.2.0Fixed in Version3.1.1 
Summary0030875: Lists.inc needs comment
DescriptionThis code is not clear, so can you add comment, describing the
logic? 256 - should be a const.
Why divide by 2, divide by 4.

  // Shrink the list if appropriate
  if (FCapacity > 256) and (FCount < FCapacity shr 2) then
  begin
    FCapacity := FCapacity shr 1;
    ReallocMem(..
  end;


TagsNo tags attached.
Fixed in Revision34861
FPCOldBugId
FPCTarget
Attached Files

Activities

Alexey Tor.

2016-11-06 20:37

reporter   ~0095618

here is good to add comment too.
function TFPList.Expand: TFPList;
var
  IncSize : Longint;
begin
  if FCount < FCapacity then exit(self);
  if FCapacity > 128*1024*1024 then IncSize := 16*1024*1024
  else if FCapacity > 8*1024*1024 then IncSize := FCapacity shr 3
  else if FCapacity > 128 then IncSize := FCapacity shr 2
  else if FCapacity > 8 then IncSize := 16
  else IncSize := 4;
  SetCapacity(FCapacity + IncSize);
  Result := Self;
end;

Marco van de Voort

2016-11-06 21:36

manager   ~0095619

If listsize>256 and less than a quarter filled reallocate to half the size.

Michael Van Canneyt

2016-11-09 22:29

administrator   ~0095727

Added some comments.

Issue History

Date Modified Username Field Change
2016-11-06 20:34 Alexey Tor. New Issue
2016-11-06 20:37 Alexey Tor. Note Added: 0095618
2016-11-06 21:36 Marco van de Voort Note Added: 0095619
2016-11-06 22:08 Michael Van Canneyt Assigned To => Michael Van Canneyt
2016-11-06 22:08 Michael Van Canneyt Status new => assigned
2016-11-09 22:29 Michael Van Canneyt Fixed in Revision => 34861
2016-11-09 22:29 Michael Van Canneyt Note Added: 0095727
2016-11-09 22:29 Michael Van Canneyt Status assigned => resolved
2016-11-09 22:29 Michael Van Canneyt Fixed in Version => 3.1.1
2016-11-09 22:29 Michael Van Canneyt Resolution open => fixed
2016-11-09 22:29 Michael Van Canneyt Target Version => 3.2.0