ropes: remove more unnecessary checks
This commit is contained in:
parent
d7a42641ab
commit
0f131b9f46
2 changed files with 5 additions and 5 deletions
|
|
@ -284,11 +284,11 @@ proc `%`*(frmt: TFormatStr, args: openArray[Rope]): Rope =
|
||||||
of '{':
|
of '{':
|
||||||
inc(i)
|
inc(i)
|
||||||
var j = 0
|
var j = 0
|
||||||
while i < length and frmt[i] in {'0'..'9'}:
|
while frmt[i] in {'0'..'9'}:
|
||||||
j = j * 10 + ord(frmt[i]) - ord('0')
|
j = j * 10 + ord(frmt[i]) - ord('0')
|
||||||
inc(i)
|
inc(i)
|
||||||
num = j
|
num = j
|
||||||
if i < length and frmt[i] == '}': inc(i)
|
if frmt[i] == '}': inc(i)
|
||||||
else: errorHandler(rInvalidFormatStr, $(frmt[i]))
|
else: errorHandler(rInvalidFormatStr, $(frmt[i]))
|
||||||
|
|
||||||
if j > high(args) + 1:
|
if j > high(args) + 1:
|
||||||
|
|
|
||||||
|
|
@ -315,15 +315,15 @@ proc `%`*(frmt: string, args: openArray[Rope]): Rope {.
|
||||||
while true:
|
while true:
|
||||||
j = j * 10 + ord(frmt[i]) - ord('0')
|
j = j * 10 + ord(frmt[i]) - ord('0')
|
||||||
inc(i)
|
inc(i)
|
||||||
if (i >= length) or frmt[i] notin {'0'..'9'}: break
|
if frmt[i] notin {'0'..'9'}: break
|
||||||
add(result, args[j-1])
|
add(result, args[j-1])
|
||||||
of '{':
|
of '{':
|
||||||
inc(i)
|
inc(i)
|
||||||
var j = 0
|
var j = 0
|
||||||
while i < length and frmt[i] in {'0'..'9'}:
|
while frmt[i] in {'0'..'9'}:
|
||||||
j = j * 10 + ord(frmt[i]) - ord('0')
|
j = j * 10 + ord(frmt[i]) - ord('0')
|
||||||
inc(i)
|
inc(i)
|
||||||
if i < length and frmt[i] == '}': inc(i)
|
if frmt[i] == '}': inc(i)
|
||||||
else: raise newException(ValueError, "invalid format string")
|
else: raise newException(ValueError, "invalid format string")
|
||||||
|
|
||||||
add(result, args[j-1])
|
add(result, args[j-1])
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue