summaryrefslogtreecommitdiff
path: root/src/cairo-hash.c
diff options
context:
space:
mode:
authorKarl Tomlinson <karlt+@karlt.net>2008-11-07 20:06:35 +0000
committerChris Wilson <chris@chris-wilson.co.uk>2008-11-07 20:49:14 +0000
commitd15fb9344bf86dd52cda0b43d3dfc49397fd84ec (patch)
treeec7d166150ed0dd49f5f37793989af466c9e0dc9 /src/cairo-hash.c
parentcd2e18ddc65959a736fc7b7f6bbd3e76af0495a9 (diff)
[hash] Set is_unique when finding an available for inserts
As we obey the rule in Cairo that we only insert if we know that there is no existing entry in the hash table, we can therefore perform a much quicker search knowing that the key is unique.
Diffstat (limited to 'src/cairo-hash.c')
-rw-r--r--src/cairo-hash.c16
1 files changed, 7 insertions, 9 deletions
diff --git a/src/cairo-hash.c b/src/cairo-hash.c
index 2317eb17..41abafd6 100644
--- a/src/cairo-hash.c
+++ b/src/cairo-hash.c
@@ -448,8 +448,8 @@ _cairo_hash_table_random_entry (cairo_hash_table_t *hash_table,
*
* Insert the entry #key_and_value into the hash table.
*
- * WARNING: It is a fatal error if an entry exists in the hash table
- * with a matching key, (this function will halt).
+ * WARNING: There must not be an existing entry in the hash table
+ * with a matching key.
*
* WARNING: It is a fatal error to insert an element while
* an iterator is running
@@ -472,13 +472,11 @@ _cairo_hash_table_insert (cairo_hash_table_t *hash_table,
assert (hash_table->iterating == 0);
entry = _cairo_hash_table_lookup_internal (hash_table,
- key_and_value, FALSE);
-
- if (ENTRY_IS_LIVE(*entry))
- {
- /* User is being bad, let's crash. */
- ASSERT_NOT_REACHED;
- }
+ key_and_value,
+ TRUE);
+ /* _cairo_hash_table_lookup_internal with key_unique = TRUE
+ * aways returns an available entry. */
+ assert (! ENTRY_IS_LIVE(*entry));
*entry = key_and_value;
hash_table->live_entries++;