Переглянути джерело

instead of stringdup(ppufile.getstring), have a getpshortstring function in entfile, and use it whereever possible. this avoids an extra shortstring copy, compared to the earlier solution

git-svn-id: trunk@35233 -
Károly Balogh 8 роки тому
батько
коміт
69a502db37
5 змінених файлів з 40 додано та 23 видалено
  1. 6 6
      compiler/aasmtai.pas
  2. 17 0
      compiler/entfile.pas
  3. 4 4
      compiler/fppu.pas
  4. 9 9
      compiler/symdef.pas
  5. 4 4
      compiler/symsym.pas

+ 6 - 6
compiler/aasmtai.pas

@@ -1021,8 +1021,8 @@ implementation
       begin
         inherited ppuload(t,ppufile);
         kind:=TSymbolPairKind(ppufile.getbyte);;
-        sym:=stringdup(ppufile.getstring);
-        value:=stringdup(ppufile.getstring);
+        sym:=ppufile.getpshortstring;
+        value:=ppufile.getpshortstring;
       end;
 
     procedure tai_symbolpair.ppuwrite(ppufile: tcompilerppufile);
@@ -1183,7 +1183,7 @@ implementation
         inherited ppuload(t,ppufile);
         sectype:=TAsmSectiontype(ppufile.getbyte);
         secalign:=ppufile.getbyte;
-        name:=stringdup(ppufile.getstring);
+        name:=ppufile.getpshortstring;
         sec:=nil;
       end;
 
@@ -3109,7 +3109,7 @@ implementation
           sd_none: ;
           sd_string:
             begin
-              data.name:=stringdup(ppufile.getstring);
+              data.name:=ppufile.getpshortstring;
               data.flags:=ppufile.getbyte;
             end;
 
@@ -3177,7 +3177,7 @@ implementation
       begin
         inherited ppuload(t, ppufile);
         stackslot:=ppufile.getlongint;
-        desc:=stringdup(ppufile.getstring);
+        desc:=ppufile.getpshortstring;
         startlab:=ppufile.getasmsymbol;
         stoplab:=ppufile.getasmsymbol;
       end;
@@ -3228,7 +3228,7 @@ implementation
     constructor tai_jcatch.ppuload(t: taitype; ppufile: tcompilerppufile);
       begin
         inherited ppuload(t, ppufile);
-        name:=stringdup(ppufile.getstring);
+        name:=ppufile.getpshortstring;
         startlab:=ppufile.getasmsymbol;
         startlab.increfs;
         stoplab:=ppufile.getasmsymbol;

+ 17 - 0
compiler/entfile.pas

@@ -270,6 +270,7 @@ type
     function  getreal:entryreal;
     function  getrealsize(sizeofreal : longint):entryreal;
     function  getstring:string;
+    function  getpshortstring:pshortstring;
     function  getansistring:ansistring;
     procedure getnormalset(out b);
     procedure getsmallset(out b);
@@ -894,6 +895,22 @@ begin
   inc(entryidx,length(result));
 end;
 
+function tentryfile.getpshortstring:pshortstring;
+var
+  len: char;
+begin
+  result:=nil;
+  len:=chr(getbyte);
+  if entryidx+ord(len)>entry.size then
+   begin
+     error:=true;
+     exit;
+   end;
+  getmem(result,ord(len)+1);
+  result^[0]:=len;
+  ReadData(result^[1],ord(len));
+  inc(entryidx,ord(len));
+end;
 
 function tentryfile.getansistring:ansistring;
 var

+ 4 - 4
compiler/fppu.pas

@@ -1124,7 +1124,7 @@ var
         getmem(derefmap,derefmapsize*sizeof(tderefmaprec));
         fillchar(derefmap^,derefmapsize*sizeof(tderefmaprec),0);
         for i:=0 to derefmapsize-1 do
-          derefmap[i].modulename:=stringdup(ppufile.getstring);
+          derefmap[i].modulename:=ppufile.getpshortstring;
       end;
 
 
@@ -1253,7 +1253,7 @@ var
            case b of
              ibjvmnamespace :
                begin
-                 namespace:=stringdup(ppufile.getstring);
+                 namespace:=ppufile.getpshortstring;
                end;
              ibmodulename :
                begin
@@ -1272,7 +1272,7 @@ var
                  if mo_has_deprecated_msg in moduleoptions then
                    begin
                      stringdispose(deprecatedmsg);
-                     deprecatedmsg:=stringdup(ppufile.getstring);
+                     deprecatedmsg:=ppufile.getpshortstring;
                    end;
                end;
              ibsourcefiles :
@@ -1299,7 +1299,7 @@ var
                readlinkcontainer(LinkOtherFrameworks);
              ibmainname:
                begin
-                 mainname:=stringdup(ppufile.getstring);
+                 mainname:=ppufile.getpshortstring;
                  if (mainaliasname<>defaultmainaliasname) then
                    Message1(scan_w_multiple_main_name_overrides,mainaliasname);
                  mainaliasname:=mainname^;

+ 9 - 9
compiler/symdef.pas

@@ -3968,9 +3968,9 @@ implementation
     constructor tabstractrecorddef.ppuload(dt:tdeftyp;ppufile:tcompilerppufile);
       begin
         inherited ppuload(dt,ppufile);
-        objrealname:=stringdup(ppufile.getstring);
+        objrealname:=ppufile.getpshortstring;
         objname:=stringdup(upper(objrealname^));
-        import_lib:=stringdup(ppufile.getstring);
+        import_lib:=ppufile.getpshortstring;
         { only used for external C++ classes and Java classes/records }
         if (import_lib^='') then
           stringdispose(import_lib);
@@ -5494,7 +5494,7 @@ implementation
            _mangledname:='';
 {$else symansistr}
          if po_has_mangledname in procoptions then
-          _mangledname:=stringdup(ppufile.getstring)
+          _mangledname:=ppufile.getpshortstring
          else
           _mangledname:=nil;
 {$endif symansistr}
@@ -5506,23 +5506,23 @@ implementation
          visibility:=tvisibility(ppufile.getbyte);
          ppufile.getsmallset(symoptions);
          if sp_has_deprecated_msg in symoptions then
-           deprecatedmsg:=stringdup(ppufile.getstring)
+           deprecatedmsg:=ppufile.getpshortstring
          else
            deprecatedmsg:=nil;
          { import stuff }
          if po_has_importdll in procoptions then
-           import_dll:=stringdup(ppufile.getstring)
+           import_dll:=ppufile.getpshortstring
          else
            import_dll:=nil;
          if po_has_importname in procoptions then
-           import_name:=stringdup(ppufile.getstring)
+           import_name:=ppufile.getpshortstring
          else
            import_name:=nil;
          import_nr:=ppufile.getword;
          if (po_msgint in procoptions) then
            messageinf.i:=ppufile.getlongint;
          if (po_msgstr in procoptions) then
-           messageinf.str:=stringdup(ppufile.getstring);
+           messageinf.str:=ppufile.getpshortstring;
          if (po_dispid in procoptions) then
            dispid:=ppufile.getlongint;
          { inline stuff }
@@ -6582,7 +6582,7 @@ implementation
       begin
          inherited ppuload(objectdef,ppufile);
          objecttype:=tobjecttyp(ppufile.getbyte);
-         objextname:=stringdup(ppufile.getstring);
+         objextname:=ppufile.getpshortstring;
          { only used for external Objective-C classes/protocols }
          if (objextname^='') then
            stringdispose(objextname);
@@ -6601,7 +6601,7 @@ implementation
            begin
               new(iidguid);
               ppufile.getguid(iidguid^);
-              iidstr:=stringdup(ppufile.getstring);
+              iidstr:=ppufile.getpshortstring;
            end;
          abstractcnt:=ppufile.getlongint;
 

+ 4 - 4
compiler/symsym.pas

@@ -563,7 +563,7 @@ implementation
          visibility:=tvisibility(ppufile.getbyte);
          ppufile.getsmallset(symoptions);
          if sp_has_deprecated_msg in symoptions then
-           deprecatedmsg:=stringdup(ppufile.getstring)
+           deprecatedmsg:=ppufile.getpshortstring
          else
            deprecatedmsg:=nil;
       end;
@@ -1754,7 +1754,7 @@ implementation
          inherited ppuload(fieldvarsym,ppufile);
          fieldoffset:=ppufile.getaint;
          if (vo_has_mangledname in varoptions) then
-           externalname:=stringdup(ppufile.getstring)
+           externalname:=ppufile.getpshortstring
          else
            externalname:=nil;
          ppuload_platform(ppufile);
@@ -1933,7 +1933,7 @@ implementation
            _mangledname:='';
 {$else symansistr}
          if vo_has_mangledname in varoptions then
-           _mangledname:=stringdup(ppufile.getstring)
+           _mangledname:=ppufile.getpshortstring
          else
            _mangledname:=nil;
 {$endif symansistr}
@@ -2231,7 +2231,7 @@ implementation
            tovar :
              ref:=ppufile.getpropaccesslist;
            toasm :
-             asmname:=stringdup(ppufile.getstring);
+             asmname:=ppufile.getpshortstring;
            toaddr :
              addroffset:=ppufile.getaword;
          end;