diff options
author | Araq <rumpf_a@web.de> | 2011-03-14 23:57:41 +0100 |
---|---|---|
committer | Araq <rumpf_a@web.de> | 2011-03-14 23:57:41 +0100 |
commit | 8d734244b14e09c97267432468ac20fcf8ff82eb (patch) | |
tree | 253eae61df789c42efe49b7c30cf38c66a3c208e /lib/pure/strutils.nim | |
parent | 6850fb73c1b9ae8d3f56a61ee37922c3cb3788d6 (diff) | |
download | Nim-8d734244b14e09c97267432468ac20fcf8ff82eb.tar.gz |
linearScanEnd pragma; string case statement optimization
Diffstat (limited to 'lib/pure/strutils.nim')
-rwxr-xr-x | lib/pure/strutils.nim | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/lib/pure/strutils.nim b/lib/pure/strutils.nim index 435f522eb..de555917c 100755 --- a/lib/pure/strutils.nim +++ b/lib/pure/strutils.nim @@ -406,14 +406,16 @@ proc ParseInt*(s: string): int {.noSideEffect, procvar, ## Parses a decimal integer value contained in `s`. If `s` is not ## a valid integer, `EInvalidValue` is raised. var L = parseutils.parseInt(s, result, 0) - if L != s.len: raise newException(EInvalidValue, "invalid integer: " & s) + if L != s.len or L == 0: + raise newException(EInvalidValue, "invalid integer: " & s) proc ParseBiggestInt*(s: string): biggestInt {.noSideEffect, procvar, rtl, extern: "nsuParseBiggestInt".} = ## Parses a decimal integer value contained in `s`. If `s` is not ## a valid integer, `EInvalidValue` is raised. var L = parseutils.parseBiggestInt(s, result, 0) - if L != s.len: raise newException(EInvalidValue, "invalid integer: " & s) + if L != s.len or L == 0: + raise newException(EInvalidValue, "invalid integer: " & s) proc ParseFloat*(s: string): float {.noSideEffect, procvar, rtl, extern: "nsuParseFloat".} = @@ -421,7 +423,8 @@ proc ParseFloat*(s: string): float {.noSideEffect, procvar, ## a valid floating point number, `EInvalidValue` is raised. ``NAN``, ## ``INF``, ``-INF`` are also supported (case insensitive comparison). var L = parseutils.parseFloat(s, result, 0) - if L != s.len: raise newException(EInvalidValue, "invalid float: " & s) + if L != s.len or L == 0: + raise newException(EInvalidValue, "invalid float: " & s) proc ParseHexInt*(s: string): int {.noSideEffect, procvar, rtl, extern: "nsuParseHexInt".} = |