projects
/
openvswitch
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
32fcdd4
)
ovs.json: Optimize __dump_string().
author
Ben Pfaff
<blp@nicira.com>
Wed, 24 Aug 2011 19:05:13 +0000
(12:05 -0700)
committer
Ben Pfaff
<blp@nicira.com>
Wed, 24 Aug 2011 19:05:13 +0000
(12:05 -0700)
Suggested-by: Reid Price <reid@nicira.com>
python/ovs/json.py
patch
|
blob
|
history
diff --git
a/python/ovs/json.py
b/python/ovs/json.py
index 67470fcbcae921f9876fb591cb420967a846e51c..97ff1bbdfb2a8f2e522470d9fdf1f99262a09f0d 100644
(file)
--- a/
python/ovs/json.py
+++ b/
python/ovs/json.py
@@
-28,15
+28,7
@@
for i in range(32):
escapes[i] = u"\\u%04x" % i
def __dump_string(stream, s):
- stream.write(u"\"")
- for c in s:
- x = ord(c)
- escape = escapes.get(x)
- if escape:
- stream.write(escape)
- else:
- stream.write(c)
- stream.write(u"\"")
+ stream.write(u'"%s"' % ''.join(escapes.get(ord(c), c) for c in s))
def to_stream(obj, stream, pretty=False, sort_keys=True):
if obj is None: