summaryrefslogtreecommitdiff
path: root/python
diff options
context:
space:
mode:
authorIlya Maximets <i.maximets@ovn.org>2021-11-22 01:09:32 +0100
committerIlya Maximets <i.maximets@ovn.org>2021-11-30 13:34:03 +0100
commitdec429168461052b62f205d211cb630c201bc28a (patch)
treef18cc07b5c8546d6ba082d95e67a9b25c3537405 /python
parent9d29990c21578a9a28b56b2ecdf8c18a1cb16b00 (diff)
downloadopenvswitch-dec429168461052b62f205d211cb630c201bc28a.tar.gz
ovsdb-data: Consolidate ovsdb atom and json strings.
ovsdb_atom_string and json_string are basically the same data structure and ovsdb-server frequently needs to convert one to another. We can avoid that by using json_string from the beginning for all ovsdb strings. So, the conversion turns into simple json_clone(), i.e. increment of a reference counter. This change gives a moderate performance boost in some scenarios, improves the code clarity and may be useful for future development. Acked-by: Mike Pattrick <mkp@redhat.com> Acked-by: Dumitru Ceara <dceara@redhat.com> Signed-off-by: Ilya Maximets <i.maximets@ovn.org>
Diffstat (limited to 'python')
-rw-r--r--python/ovs/db/data.py10
1 files changed, 6 insertions, 4 deletions
diff --git a/python/ovs/db/data.py b/python/ovs/db/data.py
index 8db21b837..3e9c5049f 100644
--- a/python/ovs/db/data.py
+++ b/python/ovs/db/data.py
@@ -569,10 +569,11 @@ class Datum(object):
s = []
if self.type.key.type == ovs.db.types.StringType:
- s += ["static struct ovsdb_atom_string %s_key_strings[%d] = {"
+ s += ["static struct json %s_key_strings[%d] = {"
% (name, n)]
for key in sorted(self.values):
- s += [' { .string = "%s", .n_refs = 2 },'
+ s += [' { .type = JSON_STRING, '
+ '.string = "%s", .count = 2 },'
% escapeCString(key.value)]
s += ["};"]
s += ["static union ovsdb_atom %s_keys[%d] = {" % (name, n)]
@@ -587,10 +588,11 @@ class Datum(object):
if self.type.value:
if self.type.value.type == ovs.db.types.StringType:
- s += ["static struct ovsdb_atom_string %s_val_strings[%d] = {"
+ s += ["static struct json %s_val_strings[%d] = {"
% (name, n)]
for k, v in sorted(self.values):
- s += [' { .string = "%s", .n_refs = 2 },'
+ s += [' { .type = JSON_STRING, '
+ '.string = "%s", .count = 2 },'
% escapeCString(v.value)]
s += ["};"]
s += ["static union ovsdb_atom %s_values[%d] = {" % (name, n)]