summaryrefslogtreecommitdiff
path: root/src/hashtab.c
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2019-12-04 21:24:53 +0100
committerBram Moolenaar <Bram@vim.org>2019-12-04 21:24:53 +0100
commit2ab2e8608f9b2c85432715bb9a7f226fdbf8cd35 (patch)
tree0a361d816527e615a7b64298e7c51c16d65fb015 /src/hashtab.c
parent9834b96820bec95d6858229d6fb256310365efff (diff)
downloadvim-git-2ab2e8608f9b2c85432715bb9a7f226fdbf8cd35.tar.gz
patch 8.1.2387: using old C style commentsv8.1.2387
Problem: Using old C style comments. Solution: Use // comments where appropriate.
Diffstat (limited to 'src/hashtab.c')
-rw-r--r--src/hashtab.c56
1 files changed, 28 insertions, 28 deletions
diff --git a/src/hashtab.c b/src/hashtab.c
index 450cf98f5..f43469fc3 100644
--- a/src/hashtab.c
+++ b/src/hashtab.c
@@ -30,18 +30,18 @@
#include "vim.h"
#if 0
-# define HT_DEBUG /* extra checks for table consistency and statistics */
+# define HT_DEBUG // extra checks for table consistency and statistics
-static long hash_count_lookup = 0; /* count number of hashtab lookups */
-static long hash_count_perturb = 0; /* count number of "misses" */
+static long hash_count_lookup = 0; // count number of hashtab lookups
+static long hash_count_perturb = 0; // count number of "misses"
#endif
-/* Magic value for algorithm that walks through the array. */
+// Magic value for algorithm that walks through the array.
#define PERTURB_SHIFT 5
static int hash_may_resize(hashtab_T *ht, int minitems);
-#if 0 /* currently not used */
+#if 0 // currently not used
/*
* Create an empty hash table.
* Returns NULL when out of memory.
@@ -64,7 +64,7 @@ hash_create(void)
void
hash_init(hashtab_T *ht)
{
- /* This zeroes all "ht_" entries and all the "hi_key" in "ht_smallarray". */
+ // This zeroes all "ht_" entries and all the "hi_key" in "ht_smallarray".
vim_memset(ht, 0, sizeof(hashtab_T));
ht->ht_array = ht->ht_smallarray;
ht->ht_mask = HT_INIT_SIZE - 1;
@@ -165,7 +165,7 @@ hash_lookup(hashtab_T *ht, char_u *key, hash_T hash)
for (perturb = hash; ; perturb >>= PERTURB_SHIFT)
{
#ifdef HT_DEBUG
- ++hash_count_perturb; /* count a "miss" for hashtab lookup */
+ ++hash_count_perturb; // count a "miss" for hashtab lookup
#endif
idx = (unsigned)((idx << 2U) + idx + perturb + 1U);
hi = &ht->ht_array[idx & ht->ht_mask];
@@ -231,7 +231,7 @@ hash_add_item(
char_u *key,
hash_T hash)
{
- /* If resizing failed before and it fails again we can't add an item. */
+ // If resizing failed before and it fails again we can't add an item.
if (ht->ht_error && hash_may_resize(ht, 0) == FAIL)
return FAIL;
@@ -241,11 +241,11 @@ hash_add_item(
hi->hi_key = key;
hi->hi_hash = hash;
- /* When the space gets low may resize the array. */
+ // When the space gets low may resize the array.
return hash_may_resize(ht, 0);
}
-#if 0 /* not used */
+#if 0 // not used
/*
* Overwrite hashtable item "hi" with "key". "hi" must point to the item that
* is to be overwritten. Thus the number of items in the hashtable doesn't
@@ -318,7 +318,7 @@ hash_unlock(hashtab_T *ht)
static int
hash_may_resize(
hashtab_T *ht,
- int minitems) /* minimal number of items */
+ int minitems) // minimal number of items
{
hashitem_T temparray[HT_INIT_SIZE];
hashitem_T *oldarray, *newarray;
@@ -330,7 +330,7 @@ hash_may_resize(
long_u newmask;
hash_T perturb;
- /* Don't resize a locked table. */
+ // Don't resize a locked table.
if (ht->ht_locked > 0)
return OK;
@@ -343,8 +343,8 @@ hash_may_resize(
if (minitems == 0)
{
- /* Return quickly for small tables with at least two NULL items. NULL
- * items are required for the lookup to decide a key isn't there. */
+ // Return quickly for small tables with at least two NULL items. NULL
+ // items are required for the lookup to decide a key isn't there.
if (ht->ht_filled < HT_INIT_SIZE - 1
&& ht->ht_array == ht->ht_smallarray)
return OK;
@@ -360,9 +360,9 @@ hash_may_resize(
return OK;
if (ht->ht_used > 1000)
- minsize = ht->ht_used * 2; /* it's big, don't make too much room */
+ minsize = ht->ht_used * 2; // it's big, don't make too much room
else
- minsize = ht->ht_used * 4; /* make plenty of room */
+ minsize = ht->ht_used * 4; // make plenty of room
}
else
{
@@ -375,20 +375,20 @@ hash_may_resize(
newsize = HT_INIT_SIZE;
while (newsize < minsize)
{
- newsize <<= 1; /* make sure it's always a power of 2 */
+ newsize <<= 1; // make sure it's always a power of 2
if (newsize == 0)
- return FAIL; /* overflow */
+ return FAIL; // overflow
}
if (newsize == HT_INIT_SIZE)
{
- /* Use the small array inside the hashdict structure. */
+ // Use the small array inside the hashdict structure.
newarray = ht->ht_smallarray;
if (ht->ht_array == newarray)
{
- /* Moving from ht_smallarray to ht_smallarray! Happens when there
- * are many removed items. Copy the items to be able to clean up
- * removed items. */
+ // Moving from ht_smallarray to ht_smallarray! Happens when there
+ // are many removed items. Copy the items to be able to clean up
+ // removed items.
mch_memmove(temparray, newarray, sizeof(temparray));
oldarray = temparray;
}
@@ -397,13 +397,13 @@ hash_may_resize(
}
else
{
- /* Allocate an array. */
+ // Allocate an array.
newarray = ALLOC_MULT(hashitem_T, newsize);
if (newarray == NULL)
{
- /* Out of memory. When there are NULL items still return OK.
- * Otherwise set ht_error, because lookup may result in a hang if
- * we add another item. */
+ // Out of memory. When there are NULL items still return OK.
+ // Otherwise set ht_error, because lookup may result in a hang if
+ // we add another item.
if (ht->ht_filled < ht->ht_mask)
return OK;
ht->ht_error = TRUE;
@@ -470,8 +470,8 @@ hash_hash(char_u *key)
return (hash_T)0;
p = key + 1;
- /* A simplistic algorithm that appears to do very well.
- * Suggested by George Reilly. */
+ // A simplistic algorithm that appears to do very well.
+ // Suggested by George Reilly.
while (*p != NUL)
hash = hash * 101 + *p++;