diff options
author | Jacek Sieka <arnetheduck@gmail.com> | 2015-03-29 22:47:29 +0800 |
---|---|---|
committer | Jacek Sieka <arnetheduck@gmail.com> | 2015-04-01 22:32:15 +0800 |
commit | bcdb5b0836a31c1302f44dd4894cd1c292354042 (patch) | |
tree | 0907639dde7d2433c7d6e544d00aa81a6e471793 /compiler/ropes.nim | |
parent | aafbe5c866e21a4078dee16f52219a1ab9fec926 (diff) | |
download | Nim-bcdb5b0836a31c1302f44dd4894cd1c292354042.tar.gz |
compiler_ropes: toRope -> rope
Diffstat (limited to 'compiler/ropes.nim')
-rw-r--r-- | compiler/ropes.nim | 28 |
1 files changed, 17 insertions, 11 deletions
diff --git a/compiler/ropes.nim b/compiler/ropes.nim index f1d4c1b6f..daf010d89 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) |