1
0
mirror of https://git.savannah.gnu.org/git/gperf.git synced 2025-12-02 21:19:24 +00:00

Use 'unsigned int' instead of 'int' where it makes sense.

This commit is contained in:
Bruno Haible
2003-03-17 09:06:26 +00:00
parent 7a8b43182a
commit 40f37680ac
5 changed files with 26 additions and 12 deletions

View File

@@ -1,3 +1,17 @@
2002-12-08 Bruno Haible <bruno@clisp.org>
* src/search.h (Search::_alpha_size): Change type to 'unsigned int'.
(Search::_asso_value_max): Likewise.
* src/search.cc (Search::prepare_asso_values): Update.
(Search::init_asso_values): Update.
(Search::~Search): Update.
* src/output.h (Output::Output): Change alpha_size type to
'unsigned int'.
(Output::_alpha_size): Change type to 'unsigned int'.
* src/output.cc (Output::Output): Change alpha_size type to
'unsigned int'.
(Output::output_hash_function): Update.
2002-12-07 Bruno Haible <bruno@clisp.org> 2002-12-07 Bruno Haible <bruno@clisp.org>
* src/options.h (OPT_CHOICE): New enum value. * src/options.h (OPT_CHOICE): New enum value.

View File

@@ -88,8 +88,8 @@ Output::Output (KeywordExt_List *head, const char *struct_decl,
unsigned int verbatim_code_lineno, unsigned int verbatim_code_lineno,
int total_keys, int max_key_len, int min_key_len, int total_keys, int max_key_len, int min_key_len,
const Positions& positions, const unsigned int *alpha_inc, const Positions& positions, const unsigned int *alpha_inc,
int total_duplicates, int alpha_size, const int *occurrences, int total_duplicates, unsigned int alpha_size,
const int *asso_values) const int *occurrences, const int *asso_values)
: _head (head), _struct_decl (struct_decl), : _head (head), _struct_decl (struct_decl),
_struct_decl_lineno (struct_decl_lineno), _return_type (return_type), _struct_decl_lineno (struct_decl_lineno), _return_type (return_type),
_struct_tag (struct_tag), _struct_tag (struct_tag),
@@ -486,7 +486,7 @@ Output::output_hash_function () const
for (int trunc = _max_hash_value; (trunc /= 10) > 0;) for (int trunc = _max_hash_value; (trunc /= 10) > 0;)
field_width++; field_width++;
for (int count = 0; count < _alpha_size; count++) for (unsigned int count = 0; count < _alpha_size; count++)
{ {
if (count > 0) if (count > 0)
printf (","); printf (",");

View File

@@ -53,7 +53,7 @@ public:
const Positions& positions, const Positions& positions,
const unsigned int *alpha_inc, const unsigned int *alpha_inc,
int total_duplicates, int total_duplicates,
int alpha_size, unsigned int alpha_size,
const int *occurrences, const int *occurrences,
const int *asso_values); const int *asso_values);
@@ -131,7 +131,7 @@ private:
/* Maximum hash value for all keywords. */ /* Maximum hash value for all keywords. */
int _max_hash_value; int _max_hash_value;
/* Size of alphabet. */ /* Size of alphabet. */
int const _alpha_size; unsigned int const _alpha_size;
/* Counts occurrences of each key set character. */ /* Counts occurrences of each key set character. */
const int * const _occurrences; const int * const _occurrences;
/* Value associated with each character. */ /* Value associated with each character. */

View File

@@ -804,10 +804,10 @@ void
Search::prepare_asso_values () Search::prepare_asso_values ()
{ {
int non_linked_length = keyword_list_length (); int non_linked_length = keyword_list_length ();
int asso_value_max; unsigned int asso_value_max;
asso_value_max = asso_value_max =
static_cast<int>(non_linked_length * option.get_size_multiple()); static_cast<unsigned int>(non_linked_length * option.get_size_multiple());
/* Round up to the next power of two. This makes it easy to ensure /* Round up to the next power of two. This makes it easy to ensure
an _asso_value[c] is >= 0 and < asso_value_max. Also, the jump value an _asso_value[c] is >= 0 and < asso_value_max. Also, the jump value
being odd, it guarantees that Search::try_asso_value() will iterate being odd, it guarantees that Search::try_asso_value() will iterate
@@ -880,7 +880,7 @@ Search::init_asso_values ()
{ {
if (_initial_asso_value < 0) if (_initial_asso_value < 0)
{ {
for (int i = 0; i < _alpha_size; i++) for (unsigned int i = 0; i < _alpha_size; i++)
_asso_values[i] = rand () & (_asso_value_max - 1); _asso_values[i] = rand () & (_asso_value_max - 1);
} }
else else
@@ -888,7 +888,7 @@ Search::init_asso_values ()
int asso_value = _initial_asso_value; int asso_value = _initial_asso_value;
asso_value = asso_value & (_asso_value_max - 1); asso_value = asso_value & (_asso_value_max - 1);
for (int i = 0; i < _alpha_size; i++) for (unsigned int i = 0; i < _alpha_size; i++)
_asso_values[i] = asso_value; _asso_values[i] = asso_value;
} }
} }
@@ -1534,7 +1534,7 @@ Search::~Search ()
{ {
fprintf (stderr, "\ndumping occurrence and associated values tables\n"); fprintf (stderr, "\ndumping occurrence and associated values tables\n");
for (int i = 0; i < _alpha_size; i++) for (unsigned int i = 0; i < _alpha_size; i++)
if (_occurrences[i]) if (_occurrences[i])
fprintf (stderr, "asso_values[%c] = %6d, occurrences[%c] = %6d\n", fprintf (stderr, "asso_values[%c] = %6d, occurrences[%c] = %6d\n",
i, _asso_values[i], i, _occurrences[i]); i, _asso_values[i], i, _occurrences[i]);

View File

@@ -138,7 +138,7 @@ public:
int _total_duplicates; int _total_duplicates;
/* Size of alphabet. */ /* Size of alphabet. */
int _alpha_size; unsigned int _alpha_size;
/* Counts occurrences of each key set character. /* Counts occurrences of each key set character.
_occurrences[c] is the number of times that c occurs among the _selchars _occurrences[c] is the number of times that c occurs among the _selchars
@@ -156,7 +156,7 @@ private:
bool * _determined; bool * _determined;
/* Exclusive upper bound for every _asso_values[c]. A power of 2. */ /* Exclusive upper bound for every _asso_values[c]. A power of 2. */
int _asso_value_max; unsigned int _asso_value_max;
/* Initial value for asso_values table. -1 means random. */ /* Initial value for asso_values table. -1 means random. */
int _initial_asso_value; int _initial_asso_value;