mirror of
https://github.com/neovim/neovim.git
synced 2025-09-30 23:18:33 +00:00
Remove long_u: hashtab: Refactor long_u type.
hashtab.h: - hash_T: long_u -> size_t. In principle, a hash value could thought of as just an unsigned number without size semantics (uint32_t or uint64_t). But it is used as index at some places, and so, size_t is also eligible. Therea re some places where assignments occur between hash_T and size_t variables, in both directions. Therefore, if we define hash_T to be of a type having a different width than that of size_t, we will have an incorrect assignment somewhere that will require an assert/guard. So the most sensible option here seems to do hast_T to be size_t too. - hashtab_T.ht_mask: long_u -> hash_T. Masks are used to be combined with hash_T values, so they should be of the same type. hashtab.c: - hash_may_resize(): oldsize: long_u -> size_t. - hash_may_resize(): newsize: long_u -> size_t. - hash_may_resize(): newmask: long_u -> hash_T.
This commit is contained in:
@@ -4,7 +4,7 @@
|
||||
#include "nvim/vim.h"
|
||||
|
||||
/// Type for hash number (hash calculation result).
|
||||
typedef long_u hash_T;
|
||||
typedef size_t hash_T;
|
||||
|
||||
/// The address of "hash_removed" is used as a magic number
|
||||
/// for hi_key to indicate a removed item.
|
||||
@@ -53,10 +53,10 @@ typedef struct hashitem_S {
|
||||
///
|
||||
/// The hashtable grows to accommodate more entries when needed.
|
||||
typedef struct hashtable_S {
|
||||
long_u ht_mask; /// mask used for hash value
|
||||
hash_T ht_mask; /// mask used for hash value
|
||||
/// (nr of items in array is "ht_mask" + 1)
|
||||
long_u ht_used; /// number of items used
|
||||
long_u ht_filled; /// number of items used or removed
|
||||
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
|
||||
/// items before growing works
|
||||
|
Reference in New Issue
Block a user