summary refs log tree commit diff stats
path: root/lib/pure/json.nim
diff options
context:
space:
mode:
authorAraq <rumpf_a@web.de>2011-05-08 17:38:34 +0200
committerAraq <rumpf_a@web.de>2011-05-08 17:38:34 +0200
commitd2e2d71d05b9a8381bf7fef7bb23da029e576c2a (patch)
tree137e4494aa119f8477204f8f974e4391f9ef1b2c /lib/pure/json.nim
parent1893f4101a59497d9c5713068ad396efdddb8574 (diff)
downloadNim-d2e2d71d05b9a8381bf7fef7bb23da029e576c2a.tar.gz
newStringOfCap implemented and used to optimize some procs
Diffstat (limited to 'lib/pure/json.nim')
-rwxr-xr-xlib/pure/json.nim3
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: