Do not convert string to string
This commit is contained in:
parent
81d04290a5
commit
e6868fabd2
|
@ -34,12 +34,12 @@ proc len*(s: Symbol): int {.borrow.}
|
||||||
|
|
||||||
proc `$`*(s: Symbol): string =
|
proc `$`*(s: Symbol): string =
|
||||||
let sym = string s
|
let sym = string s
|
||||||
if sym.len > 0 and sym.string[0] in {'A'..'z'} and not sym.anyIt(char(it) in { '\x00'..'\x19', '"', '\\', '|' }):
|
if sym.len > 0 and sym[0] in {'A'..'z'} and not sym.anyIt(char(it) in { '\x00'..'\x19', '"', '\\', '|' }):
|
||||||
result = string sym
|
result = sym
|
||||||
else:
|
else:
|
||||||
result = newStringOfCap(sym.len shl 1)
|
result = newStringOfCap(sym.len shl 1)
|
||||||
result.add('|')
|
result.add('|')
|
||||||
for c in sym.string:
|
for c in sym:
|
||||||
case c
|
case c
|
||||||
of '\\':
|
of '\\':
|
||||||
result.add("\\\\")
|
result.add("\\\\")
|
||||||
|
|
Loading…
Reference in New Issue