hashmap: adjust spacing to fix argument alignment

No actual code changes; just whitespace adjustments.

Signed-off-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Elijah Newren 2020-11-02 18:55:02 +00:00 коммит произвёл Junio C Hamano
Родитель 6474b86939
Коммит 97a39a4a93
2 изменённых файлов: 20 добавлений и 19 удалений

Просмотреть файл

@ -92,8 +92,9 @@ static void alloc_table(struct hashmap *map, unsigned int size)
} }
static inline int entry_equals(const struct hashmap *map, static inline int entry_equals(const struct hashmap *map,
const struct hashmap_entry *e1, const struct hashmap_entry *e2, const struct hashmap_entry *e1,
const void *keydata) const struct hashmap_entry *e2,
const void *keydata)
{ {
return (e1 == e2) || return (e1 == e2) ||
(e1->hash == e2->hash && (e1->hash == e2->hash &&
@ -101,7 +102,7 @@ static inline int entry_equals(const struct hashmap *map,
} }
static inline unsigned int bucket(const struct hashmap *map, static inline unsigned int bucket(const struct hashmap *map,
const struct hashmap_entry *key) const struct hashmap_entry *key)
{ {
return key->hash & (map->tablesize - 1); return key->hash & (map->tablesize - 1);
} }
@ -148,7 +149,7 @@ static int always_equal(const void *unused_cmp_data,
} }
void hashmap_init(struct hashmap *map, hashmap_cmp_fn equals_function, void hashmap_init(struct hashmap *map, hashmap_cmp_fn equals_function,
const void *cmpfn_data, size_t initial_size) const void *cmpfn_data, size_t initial_size)
{ {
unsigned int size = HASHMAP_INITIAL_SIZE; unsigned int size = HASHMAP_INITIAL_SIZE;
@ -199,7 +200,7 @@ struct hashmap_entry *hashmap_get(const struct hashmap *map,
} }
struct hashmap_entry *hashmap_get_next(const struct hashmap *map, struct hashmap_entry *hashmap_get_next(const struct hashmap *map,
const struct hashmap_entry *entry) const struct hashmap_entry *entry)
{ {
struct hashmap_entry *e = entry->next; struct hashmap_entry *e = entry->next;
for (; e; e = e->next) for (; e; e = e->next)
@ -225,8 +226,8 @@ void hashmap_add(struct hashmap *map, struct hashmap_entry *entry)
} }
struct hashmap_entry *hashmap_remove(struct hashmap *map, struct hashmap_entry *hashmap_remove(struct hashmap *map,
const struct hashmap_entry *key, const struct hashmap_entry *key,
const void *keydata) const void *keydata)
{ {
struct hashmap_entry *old; struct hashmap_entry *old;
struct hashmap_entry **e = find_entry_ptr(map, key, keydata); struct hashmap_entry **e = find_entry_ptr(map, key, keydata);
@ -249,7 +250,7 @@ struct hashmap_entry *hashmap_remove(struct hashmap *map,
} }
struct hashmap_entry *hashmap_put(struct hashmap *map, struct hashmap_entry *hashmap_put(struct hashmap *map,
struct hashmap_entry *entry) struct hashmap_entry *entry)
{ {
struct hashmap_entry *old = hashmap_remove(map, entry, NULL); struct hashmap_entry *old = hashmap_remove(map, entry, NULL);
hashmap_add(map, entry); hashmap_add(map, entry);

Просмотреть файл

@ -228,9 +228,9 @@ struct hashmap {
* prevent expensive resizing. If 0, the table is dynamically resized. * prevent expensive resizing. If 0, the table is dynamically resized.
*/ */
void hashmap_init(struct hashmap *map, void hashmap_init(struct hashmap *map,
hashmap_cmp_fn equals_function, hashmap_cmp_fn equals_function,
const void *equals_function_data, const void *equals_function_data,
size_t initial_size); size_t initial_size);
/* internal function for freeing hashmap */ /* internal function for freeing hashmap */
void hashmap_free_(struct hashmap *map, ssize_t offset); void hashmap_free_(struct hashmap *map, ssize_t offset);
@ -288,7 +288,7 @@ void hashmap_free_(struct hashmap *map, ssize_t offset);
* and if it is on stack, you can just let it go out of scope). * and if it is on stack, you can just let it go out of scope).
*/ */
static inline void hashmap_entry_init(struct hashmap_entry *e, static inline void hashmap_entry_init(struct hashmap_entry *e,
unsigned int hash) unsigned int hash)
{ {
e->hash = hash; e->hash = hash;
e->next = NULL; e->next = NULL;
@ -330,8 +330,8 @@ static inline unsigned int hashmap_get_size(struct hashmap *map)
* to `hashmap_cmp_fn` to decide whether the entry matches the key. * to `hashmap_cmp_fn` to decide whether the entry matches the key.
*/ */
struct hashmap_entry *hashmap_get(const struct hashmap *map, struct hashmap_entry *hashmap_get(const struct hashmap *map,
const struct hashmap_entry *key, const struct hashmap_entry *key,
const void *keydata); const void *keydata);
/* /*
* Returns the hashmap entry for the specified hash code and key data, * Returns the hashmap entry for the specified hash code and key data,
@ -364,7 +364,7 @@ static inline struct hashmap_entry *hashmap_get_from_hash(
* call to `hashmap_get` or `hashmap_get_next`. * call to `hashmap_get` or `hashmap_get_next`.
*/ */
struct hashmap_entry *hashmap_get_next(const struct hashmap *map, struct hashmap_entry *hashmap_get_next(const struct hashmap *map,
const struct hashmap_entry *entry); const struct hashmap_entry *entry);
/* /*
* Adds a hashmap entry. This allows to add duplicate entries (i.e. * Adds a hashmap entry. This allows to add duplicate entries (i.e.
@ -384,7 +384,7 @@ void hashmap_add(struct hashmap *map, struct hashmap_entry *entry);
* Returns the replaced entry, or NULL if not found (i.e. the entry was added). * Returns the replaced entry, or NULL if not found (i.e. the entry was added).
*/ */
struct hashmap_entry *hashmap_put(struct hashmap *map, struct hashmap_entry *hashmap_put(struct hashmap *map,
struct hashmap_entry *entry); struct hashmap_entry *entry);
/* /*
* Adds or replaces a hashmap entry contained within @keyvar, * Adds or replaces a hashmap entry contained within @keyvar,
@ -406,8 +406,8 @@ struct hashmap_entry *hashmap_put(struct hashmap *map,
* Argument explanation is the same as in `hashmap_get`. * Argument explanation is the same as in `hashmap_get`.
*/ */
struct hashmap_entry *hashmap_remove(struct hashmap *map, struct hashmap_entry *hashmap_remove(struct hashmap *map,
const struct hashmap_entry *key, const struct hashmap_entry *key,
const void *keydata); const void *keydata);
/* /*
* Removes a hashmap entry contained within @keyvar, * Removes a hashmap entry contained within @keyvar,
@ -449,7 +449,7 @@ struct hashmap_entry *hashmap_iter_next(struct hashmap_iter *iter);
/* Initializes the iterator and returns the first entry, if any. */ /* Initializes the iterator and returns the first entry, if any. */
static inline struct hashmap_entry *hashmap_iter_first(struct hashmap *map, static inline struct hashmap_entry *hashmap_iter_first(struct hashmap *map,
struct hashmap_iter *iter) struct hashmap_iter *iter)
{ {
hashmap_iter_init(map, iter); hashmap_iter_init(map, iter);
return hashmap_iter_next(iter); return hashmap_iter_next(iter);