aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEliseo Martínez <eliseomarmol@gmail.com>2014-05-24 01:17:49 +0200
committerEliseo Martínez <eliseomarmol@gmail.com>2014-05-24 01:17:49 +0200
commit0509556b93e4f3854aeb4f4841b1eb8d0d94d0b8 (patch)
treebde1484e4f8ec7ecf1b3733b841cbba62925d9b9
parentec89761e8a05fb93ed6bbde1055fbc866f7bce7e (diff)
downloadrneovim-0509556b93e4f3854aeb4f4841b1eb8d0d94d0b8.tar.gz
rneovim-0509556b93e4f3854aeb4f4841b1eb8d0d94d0b8.tar.bz2
rneovim-0509556b93e4f3854aeb4f4841b1eb8d0d94d0b8.zip
Remove long_u: hashtab: Refactor other types.
Current type of some other parameters/variables can be improved: - hashtab_T : ht_error : int -> bool. - hash_clear_all() : off : int -> unsigned int. - hash_clear_all() : todo : long -> size_t. - hash_may_resize() : todo : int -> size_t.
-rw-r--r--src/nvim/hashtab.c8
-rw-r--r--src/nvim/hashtab.h5
2 files changed, 7 insertions, 6 deletions
diff --git a/src/nvim/hashtab.c b/src/nvim/hashtab.c
index 3f5e4cf4a1..f31d2f2cbd 100644
--- a/src/nvim/hashtab.c
+++ b/src/nvim/hashtab.c
@@ -55,9 +55,9 @@ void hash_clear(hashtab_T *ht)
/// Free the array of a hash table and all contained values.
///
/// @param off the offset from start of value to start of key (@see hashitem_T).
-void hash_clear_all(hashtab_T *ht, int off)
+void hash_clear_all(hashtab_T *ht, unsigned int off)
{
- long todo = (long)ht->ht_used;
+ size_t todo = ht->ht_used;
for (hashitem_T *hi = ht->ht_array; todo > 0; ++hi) {
if (!HASHITEM_EMPTY(hi)) {
free(hi->hi_key - off);
@@ -333,7 +333,7 @@ static int hash_may_resize(hashtab_T *ht, size_t minitems)
// the right spot. The new array won't have any removed items, thus this
// is also a cleanup action.
hash_T newmask = newsize - 1;
- int todo = (int)ht->ht_used;
+ size_t todo = ht->ht_used;
for (hashitem_T *olditem = oldarray; todo > 0; ++olditem) {
if (!HASHITEM_EMPTY(olditem)) {
@@ -362,7 +362,7 @@ static int hash_may_resize(hashtab_T *ht, size_t minitems)
ht->ht_array = newarray;
ht->ht_mask = newmask;
ht->ht_filled = ht->ht_used;
- ht->ht_error = FALSE;
+ ht->ht_error = false;
return OK;
}
diff --git a/src/nvim/hashtab.h b/src/nvim/hashtab.h
index 8fba1c1ef5..dbb7fd9181 100644
--- a/src/nvim/hashtab.h
+++ b/src/nvim/hashtab.h
@@ -1,6 +1,7 @@
#ifndef NVIM_HASHTAB_H
#define NVIM_HASHTAB_H
+#include <stdbool.h>
#include "nvim/vim.h"
/// Type for hash number (hash calculation result).
@@ -58,7 +59,7 @@ typedef struct hashtable_S {
size_t ht_used; /// number of items used
size_t ht_filled; /// number of items used or removed
int ht_locked; /// counter for hash_lock()
- int ht_error; /// when set growing failed, can't add more
+ bool ht_error; /// when set growing failed, can't add more
/// items before growing works
hashitem_T *ht_array; /// points to the array, allocated when it's
/// not "ht_smallarray"
@@ -68,7 +69,7 @@ typedef struct hashtable_S {
// hashtab.c
void hash_init(hashtab_T *ht);
void hash_clear(hashtab_T *ht);
-void hash_clear_all(hashtab_T *ht, int off);
+void hash_clear_all(hashtab_T *ht, unsigned int off);
hashitem_T *hash_find(hashtab_T *ht, char_u *key);
hashitem_T *hash_lookup(hashtab_T *ht, char_u *key, hash_T hash);
void hash_debug_results(void);