From patchwork Mon Mar 20 17:50:45 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ben Pfaff X-Patchwork-Id: 741104 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from mail.linuxfoundation.org (mail.linuxfoundation.org [140.211.169.12]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3vn3QZ43TBz9s2s for ; Tue, 21 Mar 2017 04:51:02 +1100 (AEDT) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id 156F0BA4; Mon, 20 Mar 2017 17:50:54 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@mail.linuxfoundation.org Received: from smtp1.linuxfoundation.org (smtp1.linux-foundation.org [172.17.192.35]) by mail.linuxfoundation.org (Postfix) with ESMTPS id 5BA4BB73 for ; Mon, 20 Mar 2017 17:50:52 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from relay5-d.mail.gandi.net (relay5-d.mail.gandi.net [217.70.183.197]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id C91B41B4 for ; Mon, 20 Mar 2017 17:50:51 +0000 (UTC) Received: from mfilter36-d.gandi.net (mfilter36-d.gandi.net [217.70.178.167]) by relay5-d.mail.gandi.net (Postfix) with ESMTP id 9576B41C08F; Mon, 20 Mar 2017 18:50:50 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at mfilter36-d.gandi.net Received: from relay5-d.mail.gandi.net ([IPv6:::ffff:217.70.183.197]) by mfilter36-d.gandi.net (mfilter36-d.gandi.net [::ffff:10.0.15.180]) (amavisd-new, port 10024) with ESMTP id kOuppe5bZaxn; Mon, 20 Mar 2017 18:50:49 +0100 (CET) X-Originating-IP: 208.91.2.3 Received: from sigabrt.benpfaff.org (unknown [208.91.2.3]) (Authenticated sender: blp@ovn.org) by relay5-d.mail.gandi.net (Postfix) with ESMTPSA id 28F2D41C08A; Mon, 20 Mar 2017 18:50:47 +0100 (CET) From: Ben Pfaff To: dev@openvswitch.org Date: Mon, 20 Mar 2017 10:50:45 -0700 Message-Id: <20170320175045.29039-1-blp@ovn.org> X-Mailer: git-send-email 2.10.2 X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_LOW autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on smtp1.linux-foundation.org Cc: Ben Pfaff Subject: [ovs-dev] [PATCH] ovsdb-server: Drop unnecessary find_db() function. X-BeenThere: ovs-dev@openvswitch.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: ovs-dev-bounces@openvswitch.org Errors-To: ovs-dev-bounces@openvswitch.org '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 Acked-by: Andy Zhou > --- ovsdb/ovsdb-server.c | 19 ++----------------- 1 file changed, 2 insertions(+), 17 deletions(-) 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); }