From bcdb5b0836a31c1302f44dd4894cd1c292354042 Mon Sep 17 00:00:00 2001 From: Jacek Sieka Date: Sun, 29 Mar 2015 22:47:29 +0800 Subject: [PATCH] compiler_ropes: toRope -> rope --- compiler/ropes.nim | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/compiler/ropes.nim b/compiler/ropes.nim index f1d4c1b6f2..daf010d897 100644 --- a/compiler/ropes.nim +++ b/compiler/ropes.nim @@ -76,9 +76,6 @@ type rCannotOpenFile rInvalidFormatStr -proc toRope*(s: string): PRope -proc toRope*(i: BiggestInt): PRope - # implementation var errorHandler*: proc(err: TRopesError, msg: string, useWarning = false) @@ -136,13 +133,26 @@ proc insertInCache(s: string): PRope = result = newRope(s) cache[h] = result -proc toRope(s: string): PRope = +proc rope*(s: string): PRope = if s.len == 0: result = nil else: result = insertInCache(s) assert(ropeInvariant(result)) +proc rope*(i: BiggestInt): PRope = + inc gCacheIntTries + result = rope($i) + +proc rope*(f: BiggestFloat): PRope = + result = rope($f) + +# TODO Old names - change invokations to rope +proc toRope*(s: string): PRope = + result = rope(s) +proc toRope*(i: BiggestInt): PRope = + result = rope(i) + proc ropeSeqInsert(rs: var TRopeSeq, r: PRope, at: Natural) = var length = len(rs) if at > length: @@ -177,12 +187,12 @@ proc `&`*(a, b: PRope): PRope = result.right = b proc `&`*(a: PRope, b: string): PRope = - result = a & toRope(b) + result = a & rope(b) proc `&`*(a: string, b: PRope): PRope = - result = toRope(a) & b + result = rope(a) & b -proc `&`*(a: varargs[PRope]): PRope = +proc `&`*(a: openArray[PRope]): PRope = for i in countup(0, high(a)): result = result & a[i] proc add*(a: var PRope, b: PRope) = @@ -209,10 +219,6 @@ proc ropeConcat*(a: varargs[PRope]): PRope = # not overloaded version of concat to speed-up `rfmt` a little bit for i in countup(0, high(a)): result = con(result, a[i]) -proc toRope(i: BiggestInt): PRope = - inc gCacheIntTries - result = toRope($i) - # TODO Old names - change invokations to add proc app*(a: var PRope, b: PRope) = add(a, b) proc app*(a: var PRope, b: string) = add(a, b)