diff options
author | Patrick Steinhardt <ps@pks.im> | 2018-12-01 08:59:24 +0100 |
---|---|---|
committer | Patrick Steinhardt <ps@pks.im> | 2019-02-15 13:16:48 +0100 |
commit | c50a8ac2c734e4301223e39e4ddce98e6c368294 (patch) | |
tree | 85ad3a57e06b9405e7b525d4ca361cf9c137e7fd /src/strmap.h | |
parent | 84a089da3701db370b2c77e6866abe3a5065c542 (diff) | |
download | libgit2-c50a8ac2c734e4301223e39e4ddce98e6c368294.tar.gz |
maps: use high-level function to check existence of keys
Some callers were still using the tightly-coupled pattern of `lookup_index` and
`valid_index` to verify that an entry exists in a map. Instead, use the more
high-level `exists` functions to decouple map users from its implementation.
Diffstat (limited to 'src/strmap.h')
-rw-r--r-- | src/strmap.h | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/src/strmap.h b/src/strmap.h index 3317ea7b6..6ed920c37 100644 --- a/src/strmap.h +++ b/src/strmap.h @@ -88,10 +88,18 @@ int git_strmap_set(git_strmap *map, const char *key, void *value); */ int git_strmap_delete(git_strmap *map, const char *key); +/** + * Check whether a key exists in the given map. + * + * @param map map to query for the key + * @param key key to search for + * @return 0 if the key has not been found, 1 otherwise + */ +int git_strmap_exists(git_strmap *map, const char *key); + size_t git_strmap_lookup_index(git_strmap *map, const char *key); int git_strmap_valid_index(git_strmap *map, size_t idx); -int git_strmap_exists(git_strmap *map, const char *key); int git_strmap_has_data(git_strmap *map, size_t idx); const char *git_strmap_key(git_strmap *map, size_t idx); |