Browse Source

* merge duplicate strings in the LNAMES section, when writing OMF object
modules. This results in slightly smaller obj files.

git-svn-id: trunk@38967 -

nickysn 7 years ago
parent
commit
718e83954f
2 changed files with 18 additions and 2 deletions
  1. 2 2
      compiler/ogomf.pas
  2. 16 0
      compiler/omfbase.pas

+ 2 - 2
compiler/ogomf.pas

@@ -1021,7 +1021,7 @@ implementation
       begin
         inherited create(AWriter);
         cobjdata:=TOmfObjData;
-        FLNames:=TOmfOrderedNameCollection.Create;
+        FLNames:=TOmfOrderedNameCollection.Create(False);
         FSegments:=TFPHashObjectList.Create;
         FSegments.Add('',nil);
         FGroups:=TFPHashObjectList.Create;
@@ -1784,7 +1784,7 @@ implementation
       begin
         inherited create;
         cobjdata:=TOmfObjData;
-        FLNames:=TOmfOrderedNameCollection.Create;
+        FLNames:=TOmfOrderedNameCollection.Create(True);
         FExtDefs:=TFPHashObjectList.Create;
         FPubDefs:=TFPHashObjectList.Create;
         FRawRecord:=TOmfRawRecord.Create;

+ 16 - 0
compiler/omfbase.pas

@@ -233,15 +233,18 @@ interface
 
     TOmfOrderedNameCollection = class
     private
+      FAllowDuplicates: Boolean;
       FStringList: array of string;
       function GetCount: Integer;
       function GetString(Index: Integer): string;
       procedure SetString(Index: Integer; AValue: string);
     public
+      constructor Create(AAllowDuplicates: Boolean);
       function Add(const S: string): Integer;
       procedure Clear;
       property Strings [Index: Integer]: string read GetString write SetString; default;
       property Count: Integer read GetCount;
+      property AllowDuplicates: Boolean read FAllowDuplicates;
     end;
 
     { TOmfRawRecord }
@@ -1190,8 +1193,21 @@ implementation
       FStringList[Index-1]:=AValue;
     end;
 
+  constructor TOmfOrderedNameCollection.Create(AAllowDuplicates: Boolean);
+    begin
+      FAllowDuplicates:=AAllowDuplicates;
+    end;
+
   function TOmfOrderedNameCollection.Add(const S: string): Integer;
+    var
+      I: Integer;
     begin
+      if not AllowDuplicates then
+        begin
+          for I:=Low(FStringList) to High(FStringList) do
+            if FStringList[I]=S then
+              exit(I+1);
+        end;
       Result:=Length(FStringList)+1;
       SetLength(FStringList,Result);
       FStringList[Result-1]:=S;