* Patch with small speed improvements from Luiz Americo (Bug ID 17240 )

git-svn-id: trunk@15878 -
This commit is contained in:
michael 2010-08-23 07:45:55 +00:00
parent a848b6fde2
commit 4144176f2f
2 changed files with 5 additions and 6 deletions

View File

@ -30,7 +30,7 @@ Type
FScanner : TJSONScanner; FScanner : TJSONScanner;
function ParseNumber: TJSONNumber; function ParseNumber: TJSONNumber;
Protected Protected
procedure DoError(Msg: String); procedure DoError(const Msg: String);
function DoParse(AtCurrent,AllowEOF: Boolean): TJSONData; function DoParse(AtCurrent,AllowEOF: Boolean): TJSONData;
function GetNextToken: TJSONToken; function GetNextToken: TJSONToken;
function CurrentTokenString: String; function CurrentTokenString: String;
@ -115,8 +115,7 @@ begin
tkComma : DoError(SErrUnexpectedToken); tkComma : DoError(SErrUnexpectedToken);
end; end;
except except
if assigned(Result) then FreeAndNil(Result);
FreeAndNil(Result);
Raise; Raise;
end; end;
end; end;
@ -226,7 +225,7 @@ begin
Until (Result<>tkWhiteSpace); Until (Result<>tkWhiteSpace);
end; end;
Procedure TJSONParser.DoError(Msg : String); Procedure TJSONParser.DoError(const Msg : String);
Var Var
S : String; S : String;

View File

@ -63,7 +63,7 @@ type
function DoFetchToken: TJSONToken; function DoFetchToken: TJSONToken;
public public
constructor Create(Source : TStream); overload; constructor Create(Source : TStream); overload;
constructor Create(Source : String); overload; constructor Create(const Source : String); overload;
destructor Destroy; override; destructor Destroy; override;
function FetchToken: TJSONToken; function FetchToken: TJSONToken;
@ -104,7 +104,7 @@ begin
FSource.LoadFromStream(Source); FSource.LoadFromStream(Source);
end; end;
constructor TJSONScanner.Create(Source : String); constructor TJSONScanner.Create(const Source : String);
begin begin
FSource:=TStringList.Create; FSource:=TStringList.Create;
FSource.Text:=Source; FSource.Text:=Source;