mirror of
https://github.com/openvswitch/ovs
synced 2025-08-30 13:58:14 +00:00
ofproto: Use shash instead of svec for uniquifying, in reinit_ports().
No point in using an O(n log n) algorithm when an O(n) algorithm is readily available. (I'm sure that the actual performance difference, if any, does not matter in practice.) Acked-by: Jesse Gross <jesse@nicira.com>
This commit is contained in:
@@ -1481,7 +1481,8 @@ ofproto_flush_flows(struct ofproto *ofproto)
|
|||||||
static void
|
static void
|
||||||
reinit_ports(struct ofproto *p)
|
reinit_ports(struct ofproto *p)
|
||||||
{
|
{
|
||||||
struct svec devnames;
|
struct shash_node *node;
|
||||||
|
struct shash devnames;
|
||||||
struct ofport *ofport;
|
struct ofport *ofport;
|
||||||
struct odp_port *odp_ports;
|
struct odp_port *odp_ports;
|
||||||
size_t n_odp_ports;
|
size_t n_odp_ports;
|
||||||
@@ -1489,21 +1490,20 @@ reinit_ports(struct ofproto *p)
|
|||||||
|
|
||||||
COVERAGE_INC(ofproto_reinit_ports);
|
COVERAGE_INC(ofproto_reinit_ports);
|
||||||
|
|
||||||
svec_init(&devnames);
|
shash_init(&devnames);
|
||||||
HMAP_FOR_EACH (ofport, hmap_node, &p->ports) {
|
HMAP_FOR_EACH (ofport, hmap_node, &p->ports) {
|
||||||
svec_add (&devnames, ofport->opp.name);
|
shash_add_once (&devnames, ofport->opp.name, NULL);
|
||||||
}
|
}
|
||||||
dpif_port_list(p->dpif, &odp_ports, &n_odp_ports);
|
dpif_port_list(p->dpif, &odp_ports, &n_odp_ports);
|
||||||
for (i = 0; i < n_odp_ports; i++) {
|
for (i = 0; i < n_odp_ports; i++) {
|
||||||
svec_add (&devnames, odp_ports[i].devname);
|
shash_add_once (&devnames, odp_ports[i].devname, NULL);
|
||||||
}
|
}
|
||||||
free(odp_ports);
|
free(odp_ports);
|
||||||
|
|
||||||
svec_sort_unique(&devnames);
|
SHASH_FOR_EACH (node, &devnames) {
|
||||||
for (i = 0; i < devnames.n; i++) {
|
update_port(p, node->name);
|
||||||
update_port(p, devnames.names[i]);
|
|
||||||
}
|
}
|
||||||
svec_destroy(&devnames);
|
shash_destroy(&devnames);
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct ofport *
|
static struct ofport *
|
||||||
|
Reference in New Issue
Block a user