newStringOfCap implemented and used to optimize some procs
This commit is contained in:
parent
1893f4101a
commit
d2e2d71d05
10 changed files with 53 additions and 21 deletions
|
|
@ -620,7 +620,8 @@ proc nl(s: var string, ml: bool) =
|
|||
|
||||
proc escapeJson*(s: string): string =
|
||||
## Converts a string `s` to its JSON representation.
|
||||
result = "\""
|
||||
result = newStringOfCap(s.len + s.len shr 3)
|
||||
result.add("\"")
|
||||
for x in runes(s):
|
||||
var r = int(x)
|
||||
if r >= 32 and r <= 127:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue