Bläddra i källkod

Immediately set the capacity

Alligator-1 1 år sedan
förälder
incheckning
9caabdc4e7

+ 2 - 0
compiler/fppu.pas

@@ -791,6 +791,7 @@ var
         i : longint;
         deref : pderef;
       begin
+        unitimportsymsderefs.capacity:=unitimportsymsderefs.count+unitimportsyms.count;
         for i:=0 to unitimportsyms.count-1 do
           begin
             new(deref);
@@ -805,6 +806,7 @@ var
         i : longint;
         sym : tsym;
       begin
+        unitimportsyms.capacity:=unitimportsyms.count+unitimportsymsderefs.count;
         for i:=0 to unitimportsymsderefs.count-1 do
           begin
             sym:=tsym(pderef(unitimportsymsderefs[i])^.resolve);

+ 1 - 0
compiler/ncal.pas

@@ -1867,6 +1867,7 @@ implementation
         if assigned(varargsparas) then
          begin
            n.varargsparas:=tvarargsparalist.create(true);
+           n.varargsparas.capacity:=varargsparas.count;
            for i:=0 to varargsparas.count-1 do
              begin
                hp:=tparavarsym(varargsparas[i]);

+ 1 - 0
compiler/ogbase.pas

@@ -3326,6 +3326,7 @@ implementation
           exit;
         { create a list of symbols sorted by address }
         list:=TFPList.Create;
+        list.Capacity:=ExeSymbolList.Count;
         for i:=0 to ExeSymbolList.Count-1 do
           list.Add(TExeSymbol(ExeSymbolList[i]).ObjSymbol);
         list.Sort(@ByAddress);

+ 2 - 0
compiler/ogelf.pas

@@ -2271,6 +2271,7 @@ implementation
         newsections:=TFPHashObjectList.Create(false);
         allsections:=TFPList.Create;
         { copy existing sections }
+        allsections.Capacity:=ExeSectionList.Count;
         for i:=0 to ExeSectionList.Count-1 do
           allsections.add(ExeSectionList[i]);
         inserts[0]:=FindExeSection('.comment');
@@ -2688,6 +2689,7 @@ implementation
         if assigned(dynrelocsec) then
           begin
             { Append R_xx_COPY relocations }
+            dynreloclist.capacity:=dynreloclist.count+dyncopysyms.count;
             for i:=0 to dyncopysyms.count-1 do
               begin
                 objsym:=TObjSymbol(dyncopysyms[i]);

+ 2 - 0
compiler/pgentype.pas

@@ -81,10 +81,12 @@ var
   i : longint;
 begin
   result:=tspecializationcontext.create;
+  result.paramlist.capacity:=paramlist.count;
   for i:=0 to paramlist.count-1 do
     begin
       result.paramlist.add(paramlist[i]);
     end;
+  result.poslist.capacity:=poslist.count;
   for i:=0 to poslist.count-1 do
     begin
       new(posinfo);

+ 3 - 0
compiler/pgenutil.pas

@@ -728,6 +728,8 @@ uses
           tmpparampos:=current_filepos;
           if genericparams.count<>genericdef.genericparas.count then
             internalerror(2021020901);
+          poslist.capacity:=poslist.count+genericparams.count;
+          context.paramlist.capacity:=context.paramlist.count+genericparams.count;
           for i:=0 to genericparams.count-1 do
             begin
               paramname:=generic_param_hash(ttypesym(genericdef.genericparas[i]).typedef);
@@ -2961,6 +2963,7 @@ uses
 
         { add those defs back to the pending list for which we don't yet have
           all method bodies }
+        current_module.pendingspecializations.capacity:=current_module.pendingspecializations.count+readdlist.count;
         for i:=0 to readdlist.count-1 do
           current_module.pendingspecializations.add(tstoreddef(readdlist[i]).typename,readdlist[i]);
 

+ 1 - 0
compiler/procdefutil.pas

@@ -1698,6 +1698,7 @@ implementation
                   tocapture.add(sym);
             end;
 
+          convertarg.mappings.capacity:=convertarg.mappings.count+tocapture.count;
           for i:=0 to tocapture.count-1 do
             begin
               new(mapping);

+ 4 - 0
compiler/symdef.pas

@@ -2014,6 +2014,7 @@ implementation
         intfderef : pderef;
         i : longint;
       begin
+        interfacesderef.capacity:=interfacesderef.count+interfaces.count;
         for i:=0 to interfaces.count-1 do
           begin
             new(intfderef);
@@ -2026,6 +2027,7 @@ implementation
       var
         i : longint;
       begin
+        interfaces.capacity:=interfaces.count+interfacesderef.count;
         for i:=0 to interfacesderef.count-1 do
           interfaces.add(pderef(interfacesderef[i])^.resolve);
       end;
@@ -2411,6 +2413,7 @@ implementation
           begin
             if not assigned(genericparaderefs) then
               genericparaderefs:=tfplist.create;
+            genericparaderefs.capacity:=genericparaderefs.count+genericparas.count;
             for i:=0 to genericparas.count-1 do
               begin
                 sym:=tsym(genericparas.items[i]);
@@ -8084,6 +8087,7 @@ implementation
         tobjectdef(result).abstractcnt:=abstractcnt;
         if assigned(ImplementedInterfaces) then
           begin
+            tobjectdef(result).ImplementedInterfaces.capacity:=tobjectdef(result).ImplementedInterfaces.count+ImplementedInterfaces.count;
             for i:=0 to ImplementedInterfaces.count-1 do
               tobjectdef(result).ImplementedInterfaces.Add(TImplementedInterface(ImplementedInterfaces[i]).Getcopy);
           end;

+ 11 - 6
compiler/symsym.pas

@@ -1081,12 +1081,15 @@ implementation
             { this might happen for procsyms in classes that override symbols
               in a parent class that generic overloads }
             if assigned(fgenprocsymovlds) then
-              for i:=0 to fgenprocsymovlds.count-1 do
-                begin
-                  sym:=tprocsym(fgenprocsymovlds[i]);
-                  d.build(sym);
-                  fgenprocsymovldsderefs.add(pointer(ptrint(d.dataidx)));
-                end;
+              begin
+                fgenprocsymovldsderefs.capacity:=fgenprocsymovldsderefs.count+fgenprocsymovlds.count;
+                for i:=0 to fgenprocsymovlds.count-1 do
+                  begin
+                    sym:=tprocsym(fgenprocsymovlds[i]);
+                    d.build(sym);
+                    fgenprocsymovldsderefs.add(pointer(ptrint(d.dataidx)));
+                  end;
+              end;
           end;
       end;
 
@@ -1102,6 +1105,7 @@ implementation
         ProcdefList.Clear;
         if not assigned(FProcdefDerefList) then
           internalerror(200611031);
+        ProcdefList.capacity:=FProcdefDerefList.count;
         for i:=0 to FProcdefDerefList.Count-1 do
           begin
             d.dataidx:=PtrInt(FProcdefDerefList[i]);
@@ -1117,6 +1121,7 @@ implementation
             if assigned(fgenprocsymovlds) then
               begin
                 fgenprocsymovlds.clear;
+                fgenprocsymovlds.capacity:=fgenprocsymovldsderefs.count;
                 for i:= 0 to fgenprocsymovldsderefs.count-1 do
                   begin
                     d.dataidx:=ptrint(fgenprocsymovldsderefs[i]);

+ 1 - 0
compiler/symtable.pas

@@ -1784,6 +1784,7 @@ implementation
 
         sublist:=tfplist.create;
         tabstractrecordsymtable(tabstractrecorddef(fsym.vardef).symtable).get_managementoperator_offset_list(mop,sublist);
+        mop_list[mop].capacity:=mop_list[mop].count+sublist.count;
         for i:=0 to sublist.count-1 do
           begin
             entry:=pmanagementoperator_offset_entry(sublist[i]);