Message ID | 20170320175045.29039-1-blp@ovn.org |
---|---|
State | Accepted |
Headers | show |
On Mon, Mar 20, 2017 at 10:50 AM, Ben Pfaff <blp@ovn.org> wrote: > 'all_dbs' maps from a schema name to its struct db, so there's no need to > iterate the whole thing to find a database by schema name; instead, just > use the shash in the usual way. > > Also, avoid trying too hard in ovsdb_replication_init() in a similar way. > > Signed-off-by: Ben Pfaff <blp@ovn.org> Acked-by: Andy Zhou <azhou@ovn.org>>
On Mon, Mar 20, 2017 at 12:44:47PM -0700, Andy Zhou wrote: > On Mon, Mar 20, 2017 at 10:50 AM, Ben Pfaff <blp@ovn.org> wrote: > > 'all_dbs' maps from a schema name to its struct db, so there's no need to > > iterate the whole thing to find a database by schema name; instead, just > > use the shash in the usual way. > > > > Also, avoid trying too hard in ovsdb_replication_init() in a similar way. > > > > Signed-off-by: Ben Pfaff <blp@ovn.org> > > Acked-by: Andy Zhou <azhou@ovn.org>> Thanks, applied to master.
diff --git a/ovsdb/ovsdb-server.c b/ovsdb/ovsdb-server.c index 4f88500a054d..3305aa8e541e 100644 --- a/ovsdb/ovsdb-server.c +++ b/ovsdb/ovsdb-server.c @@ -145,7 +145,7 @@ ovsdb_replication_init(const char *sync_from, const char *exclude, struct shash_node *node; SHASH_FOR_EACH (node, all_dbs) { struct db *db = node->data; - replication_add_local_db(db->db->schema->name, db->db); + replication_add_local_db(node->name, db->db); } } @@ -529,21 +529,6 @@ open_db(struct server_config *config, const char *filename) return error; } -static const struct db * -find_db(const struct shash *all_dbs, const char *db_name) -{ - struct shash_node *node; - - SHASH_FOR_EACH (node, all_dbs) { - struct db *db = node->data; - if (!strcmp(db->db->schema->name, db_name)) { - return db; - } - } - - return NULL; -} - static char * OVS_WARN_UNUSED_RESULT parse_db_column__(const struct shash *all_dbs, const char *name_, char *name, @@ -574,7 +559,7 @@ parse_db_column__(const struct shash *all_dbs, table_name = tokens[1]; column_name = tokens[2]; - db = find_db(all_dbs, tokens[0]); + db = shash_find_data(all_dbs, tokens[0]); if (!db) { return xasprintf("\"%s\": no database named %s", name_, db_name); }
'all_dbs' maps from a schema name to its struct db, so there's no need to iterate the whole thing to find a database by schema name; instead, just use the shash in the usual way. Also, avoid trying too hard in ovsdb_replication_init() in a similar way. Signed-off-by: Ben Pfaff <blp@ovn.org> --- ovsdb/ovsdb-server.c | 19 ++----------------- 1 file changed, 2 insertions(+), 17 deletions(-)