diff options
author | Araq <rumpf_a@web.de> | 2011-05-08 17:38:34 +0200 |
---|---|---|
committer | Araq <rumpf_a@web.de> | 2011-05-08 17:38:34 +0200 |
commit | d2e2d71d05b9a8381bf7fef7bb23da029e576c2a (patch) | |
tree | 137e4494aa119f8477204f8f974e4391f9ef1b2c /lib/pure/json.nim | |
parent | 1893f4101a59497d9c5713068ad396efdddb8574 (diff) | |
download | Nim-d2e2d71d05b9a8381bf7fef7bb23da029e576c2a.tar.gz |
newStringOfCap implemented and used to optimize some procs
Diffstat (limited to 'lib/pure/json.nim')
-rwxr-xr-x | lib/pure/json.nim | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/lib/pure/json.nim b/lib/pure/json.nim index 75958a55f..efadf030c 100755 --- a/lib/pure/json.nim +++ b/lib/pure/json.nim @@ -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: |