MCPcopy Create free account
hub / github.com/apache/fory / get_or_default

Method get_or_default

cpp/fory/util/flat_int_map.h:243–258  ·  view source on GitHub ↗

get value if found, otherwise return default_value. @param key The key to look up @param default_value Value to return if key not found @return The stored value or default_value

Source from the content-addressed store, hash-verified

241 /// @param default_value Value to return if key not found
242 /// @return The stored value or default_value
243 FORY_ALWAYS_INLINE V get_or_default(K key, V default_value) const {
244 if (FORY_PREDICT_FALSE(key == k_empty))
245 return default_value;
246 Entry *entries = entries_.get();
247 size_t mask = mask_;
248 size_t idx = place(key);
249 while (true) {
250 Entry *entry = &entries[idx];
251 K k = entry->key;
252 if (k == key)
253 return entry->value;
254 if (k == k_empty)
255 return default_value;
256 idx = (idx + 1) & mask;
257 }
258 }
259
260 FORY_ALWAYS_INLINE bool contains(K key) const {
261 if (FORY_PREDICT_FALSE(key == k_empty))

Callers 8

type_resolver.hFile · 0.80
clone_struct_metaMethod · 0.80
get_type_infoMethod · 0.80
register_any_typeMethod · 0.80
get_type_info_by_idMethod · 0.80
TEST_FFunction · 0.80

Calls 1

getMethod · 0.65

Tested by 1

TEST_FFunction · 0.64