aboutsummaryrefslogtreecommitdiffstats
path: root/src/base
diff options
context:
space:
mode:
authorwhiteshark0 <whiteshark0@b956fd51-792f-4845-bead-9b4dfca2ff2c>2009-12-13 11:16:12 +0000
committerwhiteshark0 <whiteshark0@b956fd51-792f-4845-bead-9b4dfca2ff2c>2009-12-13 11:16:12 +0000
commit9902c756e8a15bb4582cdc43bb94378f29de0999 (patch)
treeb379ef829a0784e1c5e57c10b1fea51d6d1d84b2 /src/base
parentd803b2322d8322a8e3fab7cffb043c0c62d94c9d (diff)
downloadusdx-9902c756e8a15bb4582cdc43bb94378f29de0999.tar.gz
usdx-9902c756e8a15bb4582cdc43bb94378f29de0999.tar.xz
usdx-9902c756e8a15bb4582cdc43bb94378f29de0999.zip
use TryStrToInt and TryStrToFloat instead of try .. except block
may increase performance at least for medley branch git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@2024 b956fd51-792f-4845-bead-9b4dfca2ff2c
Diffstat (limited to '')
-rw-r--r--src/base/USong.pas18
1 files changed, 10 insertions, 8 deletions
diff --git a/src/base/USong.pas b/src/base/USong.pas
index 47200e63..151ad73d 100644
--- a/src/base/USong.pas
+++ b/src/base/USong.pas
@@ -96,7 +96,7 @@ type
function ParseLyricStringParam(const Line: RawByteString; var LinePos: integer): RawByteString;
function ParseLyricIntParam(const Line: RawByteString; var LinePos: integer): integer;
- function ParseLyricFloatParam(const Line: RawByteString; var LinePos: integer): real;
+ function ParseLyricFloatParam(const Line: RawByteString; var LinePos: integer): extended;
function ParseLyricCharParam(const Line: RawByteString; var LinePos: integer): AnsiChar;
function ParseLyricText(const Line: RawByteString; var LinePos: integer): RawByteString;
@@ -346,24 +346,26 @@ var
begin
OldLinePos := LinePos;
Str := ParseLyricStringParam(Line, LinePos);
- try
- Result := StrToInt(Str);
- except // on EConvertError
+
+ if not TryStrToInt(Str, Result) then
+ begin // on convert error
+ Result := 0;
LinePos := OldLinePos;
raise EUSDXParseException.Create('Integer expected');
end;
end;
-function TSong.ParseLyricFloatParam(const Line: RawByteString; var LinePos: integer): real;
+function TSong.ParseLyricFloatParam(const Line: RawByteString; var LinePos: integer): extended;
var
Str: RawByteString;
OldLinePos: integer;
begin
OldLinePos := LinePos;
Str := ParseLyricStringParam(Line, LinePos);
- try
- Result := StrToFloat(Str);
- except // on EConvertError
+
+ if not TryStrToFloat(Str, Result) then
+ begin // on convert error
+ Result := 0;
LinePos := OldLinePos;
raise EUSDXParseException.Create('Float expected');
end;