diff options
| author | Ben Pfaff <blp@nicira.com> | 2011-08-24 12:05:13 -0700 |
|---|---|---|
| committer | Ben Pfaff <blp@nicira.com> | 2011-08-24 12:05:13 -0700 |
| commit | e0b2332760c97b8dbe6fdd89e18634a7e8f8050e (patch) | |
| tree | 85cd7e77839a3757aca558f7d448e40429752b7f /python | |
| parent | 32fcdd44c5e43e41c285220da5db49fd9870d225 (diff) | |
| download | openvswitch-e0b2332760c97b8dbe6fdd89e18634a7e8f8050e.tar.gz | |
ovs.json: Optimize __dump_string().
Suggested-by: Reid Price <reid@nicira.com>
Diffstat (limited to 'python')
| -rw-r--r-- | python/ovs/json.py | 10 |
1 files changed, 1 insertions, 9 deletions
diff --git a/python/ovs/json.py b/python/ovs/json.py index 67470fcbc..97ff1bbdf 100644 --- 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: |
