* merge duplicate strings in the LNAMES section, when writing OMF object

modules. This results in slightly smaller obj files.

git-svn-id: trunk@38967 -
This commit is contained in:
nickysn 2018-05-10 13:07:32 +00:00
parent 200f884024
commit 718e83954f
2 changed files with 19 additions and 3 deletions

View File

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

View File

@ -233,15 +233,18 @@ interface
TOmfOrderedNameCollection = class TOmfOrderedNameCollection = class
private private
FAllowDuplicates: Boolean;
FStringList: array of string; FStringList: array of string;
function GetCount: Integer; function GetCount: Integer;
function GetString(Index: Integer): string; function GetString(Index: Integer): string;
procedure SetString(Index: Integer; AValue: string); procedure SetString(Index: Integer; AValue: string);
public public
constructor Create(AAllowDuplicates: Boolean);
function Add(const S: string): Integer; function Add(const S: string): Integer;
procedure Clear; procedure Clear;
property Strings [Index: Integer]: string read GetString write SetString; default; property Strings [Index: Integer]: string read GetString write SetString; default;
property Count: Integer read GetCount; property Count: Integer read GetCount;
property AllowDuplicates: Boolean read FAllowDuplicates;
end; end;
{ TOmfRawRecord } { TOmfRawRecord }
@ -1190,8 +1193,21 @@ implementation
FStringList[Index-1]:=AValue; FStringList[Index-1]:=AValue;
end; end;
function TOmfOrderedNameCollection.Add(const S: string): Integer; constructor TOmfOrderedNameCollection.Create(AAllowDuplicates: Boolean);
begin 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; Result:=Length(FStringList)+1;
SetLength(FStringList,Result); SetLength(FStringList,Result);
FStringList[Result-1]:=S; FStringList[Result-1]:=S;