Skip to content

Commit 629cd2f

Browse files
committed
ovsdb: Slightly simplify ovsdb_table_get_row(), ovsdb_table_put_row().
There is no value in saving a call to uuid_hash() in ovsdb_table_put_row(), because uuid_hash() is a trivial inline function, so integrate ovsdb_table_get_row__() into ovsdb_table_get_row() and simplify ovsdb_table_put_row().
1 parent 71c93bd commit 629cd2f

1 file changed

Lines changed: 5 additions & 14 deletions

File tree

ovsdb/table.c

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -192,13 +192,12 @@ ovsdb_table_destroy(struct ovsdb_table *table)
192192
}
193193
}
194194

195-
static const struct ovsdb_row *
196-
ovsdb_table_get_row__(const struct ovsdb_table *table, const struct uuid *uuid,
197-
size_t hash)
195+
const struct ovsdb_row *
196+
ovsdb_table_get_row(const struct ovsdb_table *table, const struct uuid *uuid)
198197
{
199198
struct ovsdb_row *row;
200199

201-
HMAP_FOR_EACH_WITH_HASH (row, struct ovsdb_row, hmap_node, hash,
200+
HMAP_FOR_EACH_WITH_HASH (row, struct ovsdb_row, hmap_node, uuid_hash(uuid),
202201
&table->rows) {
203202
if (uuid_equals(ovsdb_row_get_uuid(row), uuid)) {
204203
return row;
@@ -208,22 +207,14 @@ ovsdb_table_get_row__(const struct ovsdb_table *table, const struct uuid *uuid,
208207
return NULL;
209208
}
210209

211-
const struct ovsdb_row *
212-
ovsdb_table_get_row(const struct ovsdb_table *table, const struct uuid *uuid)
213-
{
214-
return ovsdb_table_get_row__(table, uuid, uuid_hash(uuid));
215-
}
216-
217210
/* This is probably not the function you want. Use ovsdb_txn_row_modify()
218211
* instead. */
219212
bool
220213
ovsdb_table_put_row(struct ovsdb_table *table, struct ovsdb_row *row)
221214
{
222215
const struct uuid *uuid = ovsdb_row_get_uuid(row);
223-
size_t hash = uuid_hash(uuid);
224-
225-
if (!ovsdb_table_get_row__(table, uuid, hash)) {
226-
hmap_insert(&table->rows, &row->hmap_node, hash);
216+
if (!ovsdb_table_get_row(table, uuid)) {
217+
hmap_insert(&table->rows, &row->hmap_node, uuid_hash(uuid));
227218
return true;
228219
} else {
229220
return false;

0 commit comments

Comments
 (0)