[map] Take const key
This commit is contained in:
parent
3d1c76f713
commit
cf20d2ec5d
|
@ -199,7 +199,7 @@ struct hb_hashmap_t
|
|||
}
|
||||
|
||||
template <typename VV>
|
||||
bool set_with_hash (K key, uint32_t hash, VV&& value, bool is_delete=false)
|
||||
bool set_with_hash (const K &key, uint32_t hash, VV&& value, bool is_delete=false)
|
||||
{
|
||||
if (unlikely (!successful)) return false;
|
||||
if (unlikely ((occupancy + occupancy / 2) >= mask && !resize ())) return false;
|
||||
|
@ -229,21 +229,21 @@ struct hb_hashmap_t
|
|||
}
|
||||
|
||||
template <typename VV>
|
||||
bool set (K key, VV&& value) { return set_with_hash (key, hb_hash (key), std::forward<VV> (value)); }
|
||||
bool set (const K &key, VV&& value) { return set_with_hash (key, hb_hash (key), std::forward<VV> (value)); }
|
||||
|
||||
const V& get_with_hash (K key, uint32_t hash) const
|
||||
const V& get_with_hash (const K &key, uint32_t hash) const
|
||||
{
|
||||
if (unlikely (!items)) return item_t::default_value ();
|
||||
auto &item = item_for_hash (key, hash);
|
||||
return item.is_real () && item == key ? item.value : item_t::default_value ();
|
||||
}
|
||||
const V& get (K key) const
|
||||
const V& get (const K &key) const
|
||||
{
|
||||
if (unlikely (!items)) return item_t::default_value ();
|
||||
return get_with_hash (key, hb_hash (key));
|
||||
}
|
||||
|
||||
void del (K key) { set_with_hash (key, hb_hash (key), item_t::default_value (), true); }
|
||||
void del (const K &key) { set_with_hash (key, hb_hash (key), item_t::default_value (), true); }
|
||||
|
||||
/* Has interface. */
|
||||
typedef const V& value_t;
|
||||
|
|
|
@ -216,15 +216,15 @@ struct hb_subset_plan_t
|
|||
{
|
||||
if (sanitized_table_cache
|
||||
&& !sanitized_table_cache->in_error ()
|
||||
&& sanitized_table_cache->has (T::tableTag)) {
|
||||
return hb_blob_reference (sanitized_table_cache->get (T::tableTag).get ());
|
||||
&& sanitized_table_cache->has (0+T::tableTag)) {
|
||||
return hb_blob_reference (sanitized_table_cache->get (0+T::tableTag).get ());
|
||||
}
|
||||
|
||||
hb::unique_ptr<hb_blob_t> table_blob {hb_sanitize_context_t ().reference_table<T> (source)};
|
||||
hb_blob_t* ret = hb_blob_reference (table_blob.get ());
|
||||
|
||||
if (likely (sanitized_table_cache))
|
||||
sanitized_table_cache->set (T::tableTag,
|
||||
sanitized_table_cache->set (0+T::tableTag,
|
||||
std::move (table_blob));
|
||||
|
||||
return ret;
|
||||
|
|
|
@ -232,7 +232,7 @@ main (int argc, char **argv)
|
|||
// See commit f657ef7e57c889309c2d9d37934368ca255f9d5b and its revert.
|
||||
//m.set (hb::unique_ptr<hb_set_t> (hb_set_get_empty ()),
|
||||
// hb::unique_ptr<hb_set_t> (hb_set_get_empty ()));
|
||||
//m.get (hb::unique_ptr<hb_set_t> (hb_set_get_empty ()));
|
||||
m.get (hb::unique_ptr<hb_set_t> (hb_set_get_empty ()));
|
||||
m.iter_ref ();
|
||||
m.keys_ref ();
|
||||
m.values_ref ();
|
||||
|
|
Loading…
Reference in New Issue