* Use const string arguments where possible. Fixes issue #40441

This commit is contained in:
Michaël Van Canneyt 2023-10-12 08:49:07 +02:00
parent ac5b96a0c9
commit 38776ca494
3 changed files with 9 additions and 9 deletions

View File

@ -654,9 +654,9 @@ Type
{$IFNDEF PAS2JS} {$IFNDEF PAS2JS}
function GetInt64s(const AName : String): Int64; function GetInt64s(const AName : String): Int64;
function GetUnicodeStrings(const AName : String): TJSONUnicodeStringType; function GetUnicodeStrings(const AName : String): TJSONUnicodeStringType;
function GetQWords(AName : String): QWord; function GetQWords(const AName : String): QWord;
procedure SetInt64s(const AName : String; const AValue: Int64); procedure SetInt64s(const AName : String; const AValue: Int64);
procedure SetQWords(AName : String; AValue: QWord); procedure SetQWords(const AName : String; AValue: QWord);
procedure SetUnicodeStrings(const AName : String; const AValue: TJSONUnicodeStringType); procedure SetUnicodeStrings(const AName : String; const AValue: TJSONUnicodeStringType);
{$ELSE} {$ELSE}
function GetNativeInts(const AName : String): NativeInt; function GetNativeInts(const AName : String): NativeInt;
@ -1507,7 +1507,7 @@ end;
procedure TJSONData.DumpJSON(S: TFPJSStream); procedure TJSONData.DumpJSON(S: TFPJSStream);
Procedure W(T : String); Procedure W(const T : String);
begin begin
if T='' then exit; if T='' then exit;
{$IFDEF PAS2JS} {$IFDEF PAS2JS}
@ -3219,7 +3219,7 @@ begin
Result:=GetElements(AName).AsInt64; Result:=GetElements(AName).AsInt64;
end; end;
function TJSONObject.GetQWords(AName : String): QWord; function TJSONObject.GetQWords(const AName : String): QWord;
begin begin
Result:=GetElements(AName).AsQWord; Result:=GetElements(AName).AsQWord;
end; end;
@ -3235,7 +3235,7 @@ begin
SetElements(AName,CreateJSON(AVAlue)); SetElements(AName,CreateJSON(AVAlue));
end; end;
procedure TJSONObject.SetQWords(AName : String; AValue: QWord); procedure TJSONObject.SetQWords(const AName : String; AValue: QWord);
begin begin
SetElements(AName,CreateJSON(AVAlue)); SetElements(AName,CreateJSON(AVAlue));
end; end;

View File

@ -56,7 +56,7 @@ Type
procedure SetSourceJSON(AValue: TJSONObject); procedure SetSourceJSON(AValue: TJSONObject);
Protected Protected
procedure Apply(aSrc, aApply: TJSONObject); virtual; procedure Apply(aSrc, aApply: TJSONObject); virtual;
procedure SaveDestJSON(aFileName : string); procedure SaveDestJSON(const aFileName : string);
procedure SaveDestJSON(aStream : TStream); procedure SaveDestJSON(aStream : TStream);
Public Public
destructor destroy; override; destructor destroy; override;
@ -201,7 +201,7 @@ begin
end; end;
end; end;
procedure TJSONApplier.SaveDestJSON(aFileName: string); procedure TJSONApplier.SaveDestJSON(const aFileName: string);
Var Var
F : TFileStream; F : TFileStream;

View File

@ -152,7 +152,7 @@ Type
procedure SetCaseInsensitive(AValue: Boolean); procedure SetCaseInsensitive(AValue: Boolean);
protected protected
// Try to parse a date. // Try to parse a date.
Function ExtractDateTime(S : String): TDateTime; Function ExtractDateTime(const S : String): TDateTime;
function GetObject(AInstance : TObject; const APropName: TJSONStringType; D: TJSONObject; PropInfo: PPropInfo): TObject; function GetObject(AInstance : TObject; const APropName: TJSONStringType; D: TJSONObject; PropInfo: PPropInfo): TObject;
procedure DoClearProperty(AObject: TObject; PropInfo: PPropInfo); virtual; procedure DoClearProperty(AObject: TObject; PropInfo: PPropInfo); virtual;
procedure DoRestoreProperty(AObject: TObject; PropInfo: PPropInfo; PropData: TJSONData); virtual; procedure DoRestoreProperty(AObject: TObject; PropInfo: PPropInfo; PropData: TJSONData); virtual;
@ -380,7 +380,7 @@ begin
Exclude(Foptions,jdoCaseInsensitive); Exclude(Foptions,jdoCaseInsensitive);
end; end;
function TJSONDeStreamer.ExtractDateTime(S: String): TDateTime; function TJSONDeStreamer.ExtractDateTime(const S: String): TDateTime;
Var Var
Fmt : String; Fmt : String;