mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-12 07:26:24 +02:00
* Optimization to ReadInteger from Alex Zolotov
git-svn-id: trunk@7163 -
This commit is contained in:
parent
986dea1cfc
commit
8c00103c8e
@ -335,20 +335,9 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
function TCustomIniFile.ReadInteger(const Section, Ident: string; Default: Longint): Longint;
|
function TCustomIniFile.ReadInteger(const Section, Ident: string; Default: Longint): Longint;
|
||||||
var
|
|
||||||
s: string;
|
|
||||||
begin
|
begin
|
||||||
Result := Default;
|
// StrToInfDef() supports hex numbers prefixed with '0x' via val()
|
||||||
s := ReadString(Section, Ident, '');
|
Result := StrToIntDef(ReadString(Section, Ident, ''), Default);
|
||||||
if s > '' then try
|
|
||||||
// convert hex string
|
|
||||||
if Pos('0X', UpperCase(s)) = 1 then
|
|
||||||
s := '$' + Copy(s, 3, Length(s) - 2);
|
|
||||||
Result := StrToInt(s);
|
|
||||||
except
|
|
||||||
on EConvertError do
|
|
||||||
else raise;
|
|
||||||
end;
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TCustomIniFile.WriteInteger(const Section, Ident: string; Value: Longint);
|
procedure TCustomIniFile.WriteInteger(const Section, Ident: string; Value: Longint);
|
||||||
|
Loading…
Reference in New Issue
Block a user