From dec429168461052b62f205d211cb630c201bc28a Mon Sep 17 00:00:00 2001 From: Ilya Maximets Date: Mon, 22 Nov 2021 01:09:32 +0100 Subject: 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 Acked-by: Dumitru Ceara Signed-off-by: Ilya Maximets --- ovsdb/rbac.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'ovsdb/rbac.c') 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; -- cgit v1.2.1