ropes: remove more unnecessary checks

This commit is contained in:
Jacek Sieka
2015-04-03 23:30:42 +08:00
parent d7a42641ab
commit 0f131b9f46
2 changed files with 5 additions and 5 deletions

View File

@@ -284,11 +284,11 @@ proc `%`*(frmt: TFormatStr, args: openArray[Rope]): Rope =
of '{':
inc(i)
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')
inc(i)
num = j
if i < length and frmt[i] == '}': inc(i)
if frmt[i] == '}': inc(i)
else: errorHandler(rInvalidFormatStr, $(frmt[i]))
if j > high(args) + 1:

View File

@@ -315,15 +315,15 @@ proc `%`*(frmt: string, args: openArray[Rope]): Rope {.
while true:
j = j * 10 + ord(frmt[i]) - ord('0')
inc(i)
if (i >= length) or frmt[i] notin {'0'..'9'}: break
if frmt[i] notin {'0'..'9'}: break
add(result, args[j-1])
of '{':
inc(i)
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')
inc(i)
if i < length and frmt[i] == '}': inc(i)
if frmt[i] == '}': inc(i)
else: raise newException(ValueError, "invalid format string")
add(result, args[j-1])