o several strings changed into ansistrings, resolves #19318, no compilation speed degrations measurable

* TCmdStr changed into an ansistring
 * command line parameter handling uses now ansistrings
 * message handling parameters are now ansistrings

git-svn-id: trunk@17469 -
This commit is contained in:
florian 2011-05-15 14:53:31 +00:00
parent f1b13dca19
commit 13285ab264
8 changed files with 75 additions and 73 deletions

View File

@ -33,6 +33,7 @@ const
type type
ppchar=^pchar; ppchar=^pchar;
TMsgStr = AnsiString;
TArrayOfPChar = array[0..1000] of pchar; TArrayOfPChar = array[0..1000] of pchar;
PArrayOfPChar = ^TArrayOfPChar; PArrayOfPChar = ^TArrayOfPChar;
@ -60,7 +61,7 @@ type
procedure CreateIdx; procedure CreateIdx;
function GetPChar(nr:longint):pchar; function GetPChar(nr:longint):pchar;
function ClearVerbosity(nr:longint):boolean; function ClearVerbosity(nr:longint):boolean;
function Get(nr:longint;const args:array of string):ansistring; function Get(nr:longint;const args:array of TMsgStr):ansistring;
end; end;
{ this will read a line until #10 or #0 and also increase p } { this will read a line until #10 or #0 and also increase p }
@ -74,11 +75,11 @@ uses
cutils; cutils;
function MsgReplace(const s:string;const args:array of string):ansistring; function MsgReplace(const s:TMsgStr;const args:array of TMsgStr):ansistring;
var var
last, last,
i : longint; i : longint;
hs : ansistring; hs : TMsgStr;
begin begin
if s='' then if s='' then
@ -169,7 +170,7 @@ var
s,s1 : string; s,s1 : string;
buf : pointer; buf : pointer;
procedure err(const msgstr:string); procedure err(const msgstr:TMsgStr);
begin begin
writeln('*** PPC, file ',fn,', error in line ',line,': ',msgstr); writeln('*** PPC, file ',fn,', error in line ',line,': ',msgstr);
error:=true; error:=true;
@ -367,7 +368,7 @@ var
i : longint; i : longint;
begin begin
i:=0; i:=0;
while not(p^ in [#0,#10]) and (i<255) do while not(p^ in [#0,#10]) and (i<256) do
begin begin
inc(i); inc(i);
GetMsgLine[i]:=p^; GetMsgLine[i]:=p^;
@ -402,7 +403,7 @@ begin
result:=true; result:=true;
end; end;
function TMessage.Get(nr:longint;const args:array of string):ansistring; function TMessage.Get(nr:longint;const args:array of TMsgStr):ansistring;
var var
hp : pchar; hp : pchar;
begin begin

View File

@ -118,7 +118,7 @@ uses
{$endif nativent} {$endif nativent}
,globtype; ,globtype;
function Compile(const cmd:string):longint; function Compile(const cmd:TCmdStr):longint;
implementation implementation
@ -163,7 +163,7 @@ begin
end; end;
procedure InitCompiler(const cmd:string); procedure InitCompiler(const cmd:TCmdStr);
begin begin
if CompilerInited then if CompilerInited then
DoneCompiler; DoneCompiler;
@ -197,7 +197,7 @@ begin
end; end;
function Compile(const cmd:string):longint; function Compile(const cmd:TCmdStr):longint;
{$maxfpuregisters 0} {$maxfpuregisters 0}

View File

@ -35,9 +35,10 @@ unit fppu;
interface interface
uses uses
cutils,cclasses, cmsgs,verbose,
globtype,globals,finput,fmodule, cutils,cclasses,
symbase,ppu,symtype; globtype,globals,finput,fmodule,
symbase,ppu,symtype;
type type
@ -77,7 +78,7 @@ interface
procedure load_implementation; procedure load_implementation;
procedure load_usedunits; procedure load_usedunits;
procedure printcomments; procedure printcomments;
procedure queuecomment(s:string;v,w:longint); procedure queuecomment(const s:TMsgStr;v,w:longint);
procedure writesourcefiles; procedure writesourcefiles;
procedure writeusedunit(intf:boolean); procedure writeusedunit(intf:boolean);
procedure writelinkcontainer(var p:tlinkcontainer;id:byte;strippath:boolean); procedure writelinkcontainer(var p:tlinkcontainer;id:byte;strippath:boolean);
@ -108,7 +109,7 @@ implementation
uses uses
SysUtils, SysUtils,
cfileutl, cfileutl,
verbose,systems,version, systems,version,
symtable, symsym, symtable, symsym,
wpoinfo, wpoinfo,
scanner, scanner,
@ -155,7 +156,7 @@ var
inherited reset; inherited reset;
end; end;
procedure tppumodule.queuecomment(s:string;v,w:longint); procedure tppumodule.queuecomment(const s:TMsgStr;v,w:longint);
begin begin
if comments = nil then if comments = nil then
comments := TCmdStrList.create; comments := TCmdStrList.create;
@ -1397,7 +1398,7 @@ var
localsymtable:=tstaticsymtable.create(modulename^,moduleid); localsymtable:=tstaticsymtable.create(modulename^,moduleid);
tstaticsymtable(localsymtable).ppuload(ppufile); tstaticsymtable(localsymtable).ppuload(ppufile);
end; end;
{ we can now derefence all pointers to the implementation parts } { we can now derefence all pointers to the implementation parts }
tstoredsymtable(globalsymtable).derefimpl; tstoredsymtable(globalsymtable).derefimpl;
if assigned(localsymtable) then if assigned(localsymtable) then

View File

@ -1402,7 +1402,7 @@ implementation
procedure get_exepath; procedure get_exepath;
var var
localExepath : TCmdStr; localExepath : TCmdStr;
exeName:TCmdStr; exeName:TCmdStr;
{$ifdef need_path_search} {$ifdef need_path_search}
hs1 : TPathStr; hs1 : TPathStr;

View File

@ -32,7 +32,7 @@ interface
executed from the FPC application. In some circomstances, this can be more executed from the FPC application. In some circomstances, this can be more
than 255 characters. That's why using Ansi Strings} than 255 characters. That's why using Ansi Strings}
TCmdStr = AnsiString; TCmdStr = AnsiString;
TPathStr = String; TPathStr = AnsiString;
{ Integer type corresponding to pointer size } { Integer type corresponding to pointer size }
{$ifdef cpu64bitaddr} {$ifdef cpu64bitaddr}

View File

@ -52,15 +52,15 @@ Type
procedure WriteInfo; procedure WriteInfo;
procedure WriteHelpPages; procedure WriteHelpPages;
procedure WriteQuickInfo; procedure WriteQuickInfo;
procedure IllegalPara(const opt:string); procedure IllegalPara(const opt:TCmdStr);
procedure UnsupportedPara(const opt:string); procedure UnsupportedPara(const opt:TCmdStr);
procedure IgnoredPara(const opt:string); procedure IgnoredPara(const opt:TCmdStr);
function Unsetbool(var Opts:TCmdStr; Pos: Longint):boolean; function Unsetbool(var Opts:TCmdStr; Pos: Longint):boolean;
procedure interpret_option(const opt :string;ispara:boolean); procedure interpret_option(const opt :TCmdStr;ispara:boolean);
procedure Interpret_envvar(const envname : string); procedure Interpret_envvar(const envname : TCmdStr);
procedure Interpret_file(const filename : string); procedure Interpret_file(const filename : TPathStr);
procedure Read_Parameters; procedure Read_Parameters;
procedure parsecmd(cmd:string); procedure parsecmd(cmd:TCmdStr);
procedure TargetOptions(def:boolean); procedure TargetOptions(def:boolean);
procedure CheckOptionsCompatibility; procedure CheckOptionsCompatibility;
procedure ForceStaticLinking; procedure ForceStaticLinking;
@ -71,7 +71,7 @@ Type
var var
coption : TOptionClass; coption : TOptionClass;
procedure read_arguments(cmd:string); procedure read_arguments(cmd:TCmdStr);
implementation implementation
@ -440,7 +440,7 @@ begin
end; end;
procedure Toption.IllegalPara(const opt:string); procedure Toption.IllegalPara(const opt:TCmdStr);
begin begin
Message1(option_illegal_para,opt); Message1(option_illegal_para,opt);
Message(option_help_pages_para); Message(option_help_pages_para);
@ -448,14 +448,14 @@ begin
end; end;
procedure toption.UnsupportedPara(const opt: string); procedure toption.UnsupportedPara(const opt: TCmdStr);
begin begin
Message1(option_unsupported_target,opt); Message1(option_unsupported_target,opt);
StopOptions(1); StopOptions(1);
end; end;
procedure toption.IgnoredPara(const opt: string); procedure toption.IgnoredPara(const opt: TCmdStr);
begin begin
Message1(option_ignored_target,opt); Message1(option_ignored_target,opt);
end; end;
@ -488,7 +488,7 @@ begin
end; end;
procedure TOption.interpret_option(const opt:string;ispara:boolean); procedure TOption.interpret_option(const opt:TCmdStr;ispara:boolean);
var var
code : integer; code : integer;
c : char; c : char;
@ -517,7 +517,7 @@ begin
case opt[1] of case opt[1] of
'-' : '-' :
begin begin
more:=Copy(opt,3,255); more:=Copy(opt,3,2147483647);
if firstpass then if firstpass then
Message1(option_interpreting_firstpass_option,opt) Message1(option_interpreting_firstpass_option,opt)
else else
@ -1769,9 +1769,9 @@ begin
end; end;
procedure Toption.Interpret_file(const filename : string); procedure Toption.Interpret_file(const filename : TPathStr);
procedure RemoveSep(var fn:string); procedure RemoveSep(var fn:TPathStr);
var var
i : longint; i : longint;
begin begin
@ -1785,7 +1785,7 @@ procedure Toption.Interpret_file(const filename : string);
fn:=copy(fn,1,i); fn:=copy(fn,1,i);
end; end;
function GetName(var fn:string):string; function GetName(var fn:TPathStr):TPathStr;
var var
i : longint; i : longint;
begin begin
@ -1801,7 +1801,7 @@ const
var var
f : text; f : text;
s, tmp, s, tmp,
opts : string; opts : TCmdStr;
skip : array[0..maxlevel] of boolean; skip : array[0..maxlevel] of boolean;
line, line,
level : longint; level : longint;
@ -1954,14 +1954,14 @@ begin
end; end;
procedure Toption.Interpret_envvar(const envname : string); procedure Toption.Interpret_envvar(const envname : TCmdStr);
var var
argstart, argstart,
env, env,
pc : pchar; pc : pchar;
arglen : longint; arglen : longint;
quote : set of char; quote : set of char;
hs : string; hs : TCmdStr;
begin begin
Message1(option_using_env,envname); Message1(option_using_env,envname);
env:=GetEnvPChar(envname); env:=GetEnvPChar(envname);
@ -2013,14 +2013,14 @@ end;
procedure toption.read_parameters; procedure toption.read_parameters;
var var
opts : string; opts : TCmdStr;
paramindex : longint; paramindex : longint;
begin begin
paramindex:=0; paramindex:=0;
while paramindex<paramcount do while paramindex<paramcount do
begin begin
inc(paramindex); inc(paramindex);
opts:=system.paramstr(paramindex); opts:=objpas.paramstr(paramindex);
case opts[1] of case opts[1] of
'@' : '@' :
if not firstpass then if not firstpass then
@ -2043,10 +2043,10 @@ begin
end; end;
procedure toption.parsecmd(cmd:string); procedure toption.parsecmd(cmd:TCmdStr);
var var
i,ps : longint; i,ps : longint;
opts : string; opts : TCmdStr;
begin begin
while (cmd<>'') do while (cmd<>'') do
begin begin
@ -2054,7 +2054,7 @@ begin
delete(cmd,1,1); delete(cmd,1,1);
i:=pos(' ',cmd); i:=pos(' ',cmd);
if i=0 then if i=0 then
i:=256; i:=2147483647;
opts:=Copy(cmd,1,i-1); opts:=Copy(cmd,1,i-1);
Delete(cmd,1,i); Delete(cmd,1,i);
case opts[1] of case opts[1] of
@ -2351,7 +2351,7 @@ begin
end; end;
procedure read_arguments(cmd:string); procedure read_arguments(cmd:TCmdStr);
var var
env: ansistring; env: ansistring;
i : tfeature; i : tfeature;

View File

@ -1684,8 +1684,8 @@ In case not, the value returned can be arbitrary.
foundfile : TCmdStr; foundfile : TCmdStr;
path, path,
name, name,
args,
hs : tpathstr; hs : tpathstr;
args : string;
hp : tinputfile; hp : tinputfile;
found : boolean; found : boolean;
begin begin

View File

@ -70,7 +70,7 @@ interface
paraprintnodetree : byte; paraprintnodetree : byte;
type type
tmsgqueueevent = procedure(s:string;v,w:longint) of object; tmsgqueueevent = procedure(const s:TMsgStr;v,w:longint) of object;
const const
msgfilename : string = ''; msgfilename : string = '';
@ -88,25 +88,25 @@ interface
procedure Comment(l:longint;s:ansistring); procedure Comment(l:longint;s:ansistring);
function MessagePchar(w:longint):pchar; function MessagePchar(w:longint):pchar;
procedure Message(w:longint;onqueue:tmsgqueueevent=nil); procedure Message(w:longint;onqueue:tmsgqueueevent=nil);
procedure Message1(w:longint;const s1:string;onqueue:tmsgqueueevent=nil); procedure Message1(w:longint;const s1:TMsgStr;onqueue:tmsgqueueevent=nil);
procedure Message2(w:longint;const s1,s2:string;onqueue:tmsgqueueevent=nil); procedure Message2(w:longint;const s1,s2:TMsgStr;onqueue:tmsgqueueevent=nil);
procedure Message3(w:longint;const s1,s2,s3:string;onqueue:tmsgqueueevent=nil); procedure Message3(w:longint;const s1,s2,s3:TMsgStr;onqueue:tmsgqueueevent=nil);
procedure Message4(w:longint;const s1,s2,s3,s4:string;onqueue:tmsgqueueevent=nil); procedure Message4(w:longint;const s1,s2,s3,s4:TMsgStr;onqueue:tmsgqueueevent=nil);
procedure MessagePos(const pos:tfileposinfo;w:longint;onqueue:tmsgqueueevent=nil); procedure MessagePos(const pos:tfileposinfo;w:longint;onqueue:tmsgqueueevent=nil);
procedure MessagePos1(const pos:tfileposinfo;w:longint;const s1:string;onqueue:tmsgqueueevent=nil); procedure MessagePos1(const pos:tfileposinfo;w:longint;const s1:TMsgStr;onqueue:tmsgqueueevent=nil);
procedure MessagePos2(const pos:tfileposinfo;w:longint;const s1,s2:string;onqueue:tmsgqueueevent=nil); procedure MessagePos2(const pos:tfileposinfo;w:longint;const s1,s2:TMsgStr;onqueue:tmsgqueueevent=nil);
procedure MessagePos3(const pos:tfileposinfo;w:longint;const s1,s2,s3:string;onqueue:tmsgqueueevent=nil); procedure MessagePos3(const pos:tfileposinfo;w:longint;const s1,s2,s3:TMsgStr;onqueue:tmsgqueueevent=nil);
procedure MessagePos4(const pos:tfileposinfo;w:longint;const s1,s2,s3,s4:string;onqueue:tmsgqueueevent=nil); procedure MessagePos4(const pos:tfileposinfo;w:longint;const s1,s2,s3,s4:TMsgStr;onqueue:tmsgqueueevent=nil);
{ message calls with codegenerror support } { message calls with codegenerror support }
procedure cgmessage(t : longint); procedure cgmessage(t : longint);
procedure cgmessage1(t : longint;const s : string); procedure cgmessage1(t : longint;const s : TMsgStr);
procedure cgmessage2(t : longint;const s1,s2 : string); procedure cgmessage2(t : longint;const s1,s2 : TMsgStr);
procedure cgmessage3(t : longint;const s1,s2,s3 : string); procedure cgmessage3(t : longint;const s1,s2,s3 : TMsgStr);
procedure CGMessagePos(const pos:tfileposinfo;t:longint); procedure CGMessagePos(const pos:tfileposinfo;t:longint);
procedure CGMessagePos1(const pos:tfileposinfo;t:longint;const s1:string); procedure CGMessagePos1(const pos:tfileposinfo;t:longint;const s1:TMsgStr);
procedure CGMessagePos2(const pos:tfileposinfo;t:longint;const s1,s2:string); procedure CGMessagePos2(const pos:tfileposinfo;t:longint;const s1,s2:TMsgStr);
procedure CGMessagePos3(const pos:tfileposinfo;t:longint;const s1,s2,s3:string); procedure CGMessagePos3(const pos:tfileposinfo;t:longint;const s1,s2,s3:TMsgStr);
procedure FlushOutput; procedure FlushOutput;
@ -697,7 +697,7 @@ implementation
end; end;
procedure Message1(w:longint;const s1:string;onqueue:tmsgqueueevent=nil); procedure Message1(w:longint;const s1:TMsgStr;onqueue:tmsgqueueevent=nil);
begin begin
MaybeLoadMessageFile; MaybeLoadMessageFile;
@ -705,21 +705,21 @@ implementation
end; end;
procedure Message2(w:longint;const s1,s2:string;onqueue:tmsgqueueevent=nil); procedure Message2(w:longint;const s1,s2:TMsgStr;onqueue:tmsgqueueevent=nil);
begin begin
MaybeLoadMessageFile; MaybeLoadMessageFile;
Msg2Comment(msg^.Get(w,[s1,s2]),w,onqueue); Msg2Comment(msg^.Get(w,[s1,s2]),w,onqueue);
end; end;
procedure Message3(w:longint;const s1,s2,s3:string;onqueue:tmsgqueueevent=nil); procedure Message3(w:longint;const s1,s2,s3:TMsgStr;onqueue:tmsgqueueevent=nil);
begin begin
MaybeLoadMessageFile; MaybeLoadMessageFile;
Msg2Comment(msg^.Get(w,[s1,s2,s3]),w,onqueue); Msg2Comment(msg^.Get(w,[s1,s2,s3]),w,onqueue);
end; end;
procedure Message4(w:longint;const s1,s2,s3,s4:string;onqueue:tmsgqueueevent=nil); procedure Message4(w:longint;const s1,s2,s3,s4:TMsgStr;onqueue:tmsgqueueevent=nil);
begin begin
MaybeLoadMessageFile; MaybeLoadMessageFile;
Msg2Comment(msg^.Get(w,[s1,s2,s3,s4]),w,onqueue); Msg2Comment(msg^.Get(w,[s1,s2,s3,s4]),w,onqueue);
@ -738,7 +738,7 @@ implementation
end; end;
procedure MessagePos1(const pos:tfileposinfo;w:longint;const s1:string;onqueue:tmsgqueueevent=nil); procedure MessagePos1(const pos:tfileposinfo;w:longint;const s1:TMsgStr;onqueue:tmsgqueueevent=nil);
var var
oldpos : tfileposinfo; oldpos : tfileposinfo;
begin begin
@ -750,7 +750,7 @@ implementation
end; end;
procedure MessagePos2(const pos:tfileposinfo;w:longint;const s1,s2:string;onqueue:tmsgqueueevent=nil); procedure MessagePos2(const pos:tfileposinfo;w:longint;const s1,s2:TMsgStr;onqueue:tmsgqueueevent=nil);
var var
oldpos : tfileposinfo; oldpos : tfileposinfo;
begin begin
@ -762,7 +762,7 @@ implementation
end; end;
procedure MessagePos3(const pos:tfileposinfo;w:longint;const s1,s2,s3:string;onqueue:tmsgqueueevent=nil); procedure MessagePos3(const pos:tfileposinfo;w:longint;const s1,s2,s3:TMsgStr;onqueue:tmsgqueueevent=nil);
var var
oldpos : tfileposinfo; oldpos : tfileposinfo;
begin begin
@ -774,7 +774,7 @@ implementation
end; end;
procedure MessagePos4(const pos:tfileposinfo;w:longint;const s1,s2,s3,s4:string;onqueue:tmsgqueueevent=nil); procedure MessagePos4(const pos:tfileposinfo;w:longint;const s1,s2,s3,s4:TMsgStr;onqueue:tmsgqueueevent=nil);
var var
oldpos : tfileposinfo; oldpos : tfileposinfo;
begin begin
@ -802,7 +802,7 @@ implementation
end; end;
end; end;
procedure cgmessage1(t : longint;const s : string); procedure cgmessage1(t : longint;const s : TMsgStr);
var var
olderrorcount : longint; olderrorcount : longint;
begin begin
@ -814,7 +814,7 @@ implementation
end; end;
end; end;
procedure cgmessage2(t : longint;const s1,s2 : string); procedure cgmessage2(t : longint;const s1,s2 : TMsgStr);
var var
olderrorcount : longint; olderrorcount : longint;
begin begin
@ -826,7 +826,7 @@ implementation
end; end;
end; end;
procedure cgmessage3(t : longint;const s1,s2,s3 : string); procedure cgmessage3(t : longint;const s1,s2,s3 : TMsgStr);
var var
olderrorcount : longint; olderrorcount : longint;
begin begin
@ -851,7 +851,7 @@ implementation
end; end;
end; end;
procedure cgmessagepos1(const pos:tfileposinfo;t : longint;const s1 : string); procedure cgmessagepos1(const pos:tfileposinfo;t : longint;const s1 : TMsgStr);
var var
olderrorcount : longint; olderrorcount : longint;
begin begin
@ -863,7 +863,7 @@ implementation
end; end;
end; end;
procedure cgmessagepos2(const pos:tfileposinfo;t : longint;const s1,s2 : string); procedure cgmessagepos2(const pos:tfileposinfo;t : longint;const s1,s2 : TMsgStr);
var var
olderrorcount : longint; olderrorcount : longint;
begin begin
@ -875,7 +875,7 @@ implementation
end; end;
end; end;
procedure cgmessagepos3(const pos:tfileposinfo;t : longint;const s1,s2,s3 : string); procedure cgmessagepos3(const pos:tfileposinfo;t : longint;const s1,s2,s3 : TMsgStr);
var var
olderrorcount : longint; olderrorcount : longint;
begin begin