diff options
author | Ilya Maximets <i.maximets@ovn.org> | 2021-11-22 01:09:32 +0100 |
---|---|---|
committer | Ilya Maximets <i.maximets@ovn.org> | 2021-11-30 13:34:03 +0100 |
commit | dec429168461052b62f205d211cb630c201bc28a (patch) | |
tree | f18cc07b5c8546d6ba082d95e67a9b25c3537405 /ovsdb/rbac.c | |
parent | 9d29990c21578a9a28b56b2ecdf8c18a1cb16b00 (diff) | |
download | openvswitch-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 'ovsdb/rbac.c')
-rw-r--r-- | ovsdb/rbac.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/ovsdb/rbac.c b/ovsdb/rbac.c index ff411675f..a3fe97120 100644 --- a/ovsdb/rbac.c +++ b/ovsdb/rbac.c @@ -53,8 +53,8 @@ ovsdb_find_row_by_string_key(const struct ovsdb_table *table, HMAP_FOR_EACH (row, hmap_node, &table->rows) { const struct ovsdb_datum *datum = &row->fields[column->index]; for (size_t i = 0; i < datum->n; i++) { - if (datum->keys[i].s->string[0] && - !strcmp(key, datum->keys[i].s->string)) { + const char *row_key = json_string(datum->keys[i].s); + if (row_key[0] && !strcmp(key, row_key)) { return row; } } @@ -113,7 +113,7 @@ ovsdb_rbac_authorized(const struct ovsdb_row *perms, } for (i = 0; i < datum->n; i++) { - const char *name = datum->keys[i].s->string; + const char *name = json_string(datum->keys[i].s); const char *value = NULL; bool is_map; @@ -271,7 +271,7 @@ rbac_column_modification_permitted(const struct ovsdb_column *column, size_t i; for (i = 0; i < modifiable->n; i++) { - char *name = modifiable->keys[i].s->string; + const char *name = json_string(modifiable->keys[i].s); if (!strcmp(name, column->name)) { return true; |