From 0f131b9f46aed4bd077c2c04e63dc0cacc348930 Mon Sep 17 00:00:00 2001 From: Jacek Sieka Date: Fri, 3 Apr 2015 23:30:42 +0800 Subject: [PATCH] ropes: remove more unnecessary checks --- compiler/ropes.nim | 4 ++-- lib/pure/ropes.nim | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/compiler/ropes.nim b/compiler/ropes.nim index 160b1a4c6e..0da5a06cec 100644 --- a/compiler/ropes.nim +++ b/compiler/ropes.nim @@ -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: diff --git a/lib/pure/ropes.nim b/lib/pure/ropes.nim index af5c50521d..3959b930f2 100644 --- a/lib/pure/ropes.nim +++ b/lib/pure/ropes.nim @@ -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])