compiler_ropes: toRope -> rope
This commit is contained in:
parent
aafbe5c866
commit
bcdb5b0836
1 changed files with 17 additions and 11 deletions
|
|
@ -76,9 +76,6 @@ type
|
||||||
rCannotOpenFile
|
rCannotOpenFile
|
||||||
rInvalidFormatStr
|
rInvalidFormatStr
|
||||||
|
|
||||||
proc toRope*(s: string): PRope
|
|
||||||
proc toRope*(i: BiggestInt): PRope
|
|
||||||
|
|
||||||
# implementation
|
# implementation
|
||||||
|
|
||||||
var errorHandler*: proc(err: TRopesError, msg: string, useWarning = false)
|
var errorHandler*: proc(err: TRopesError, msg: string, useWarning = false)
|
||||||
|
|
@ -136,13 +133,26 @@ proc insertInCache(s: string): PRope =
|
||||||
result = newRope(s)
|
result = newRope(s)
|
||||||
cache[h] = result
|
cache[h] = result
|
||||||
|
|
||||||
proc toRope(s: string): PRope =
|
proc rope*(s: string): PRope =
|
||||||
if s.len == 0:
|
if s.len == 0:
|
||||||
result = nil
|
result = nil
|
||||||
else:
|
else:
|
||||||
result = insertInCache(s)
|
result = insertInCache(s)
|
||||||
assert(ropeInvariant(result))
|
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) =
|
proc ropeSeqInsert(rs: var TRopeSeq, r: PRope, at: Natural) =
|
||||||
var length = len(rs)
|
var length = len(rs)
|
||||||
if at > length:
|
if at > length:
|
||||||
|
|
@ -177,12 +187,12 @@ proc `&`*(a, b: PRope): PRope =
|
||||||
result.right = b
|
result.right = b
|
||||||
|
|
||||||
proc `&`*(a: PRope, b: string): PRope =
|
proc `&`*(a: PRope, b: string): PRope =
|
||||||
result = a & toRope(b)
|
result = a & rope(b)
|
||||||
|
|
||||||
proc `&`*(a: string, b: PRope): PRope =
|
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]
|
for i in countup(0, high(a)): result = result & a[i]
|
||||||
|
|
||||||
proc add*(a: var PRope, b: PRope) =
|
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
|
# not overloaded version of concat to speed-up `rfmt` a little bit
|
||||||
for i in countup(0, high(a)): result = con(result, a[i])
|
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
|
# TODO Old names - change invokations to add
|
||||||
proc app*(a: var PRope, b: PRope) = add(a, b)
|
proc app*(a: var PRope, b: PRope) = add(a, b)
|
||||||
proc app*(a: var PRope, b: string) = add(a, b)
|
proc app*(a: var PRope, b: string) = add(a, b)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue