mirror of
https://git.savannah.gnu.org/git/gperf.git
synced 2025-12-02 13:09:22 +00:00
Renamings and small reorganizations.
This commit is contained in:
15
ChangeLog
15
ChangeLog
@@ -1,5 +1,20 @@
|
||||
2002-12-12 Bruno Haible <bruno@clisp.org>
|
||||
|
||||
* src/search.h (Search::keyword_list_length, Search::max_key_length,
|
||||
Search::get_max_keysig_size, Search::prepare): Remove declarations.
|
||||
(Search::prepare): Renamed from Search::preprepare.
|
||||
(Search::_max_selchars_length): New field.
|
||||
* src/search.cc (Search::prepare): Renamed from Search::preprepare.
|
||||
(Search::prepare_asso_values): Merged with old Search::prepare.
|
||||
Initialize _max_selchars_length.
|
||||
(Search::keyword_list_length): Remove function. Use _list_len instead.
|
||||
(Search::max_key_length): Remove function. Use _max_key_len instead.
|
||||
(Search::get_max_keysig_size): Remove function. Use
|
||||
_max_selchars_length instead.
|
||||
(Search::count_possible_collisions, Search::find_asso_values): Update.
|
||||
(Search::find_good_asso_values): Call just prepare_asso_values.
|
||||
(Search::~Search): Update.
|
||||
|
||||
* src/output.h (Output::output_asso_values_ref): New declaration.
|
||||
* src/output.cc (char_to_index): Remove variable.
|
||||
(Output::output_asso_values_ref): New function.
|
||||
|
||||
@@ -92,7 +92,7 @@ Search::Search (KeywordExt_List *list)
|
||||
}
|
||||
|
||||
void
|
||||
Search::preprepare ()
|
||||
Search::prepare ()
|
||||
{
|
||||
KeywordExt_List *temp;
|
||||
|
||||
@@ -670,14 +670,19 @@ Search::find_alpha_inc ()
|
||||
|
||||
/* ======================= Finding good asso_values ======================== */
|
||||
|
||||
/* Initializes the asso_values[] related parameters. */
|
||||
|
||||
void
|
||||
Search::prepare ()
|
||||
Search::prepare_asso_values ()
|
||||
{
|
||||
KeywordExt_List *temp;
|
||||
|
||||
/* Initialize each keyword's _selchars array. */
|
||||
init_selchars_multiset(_key_positions, _alpha_unify, _alpha_inc);
|
||||
|
||||
/* Compute the maximum _selchars_length over all keywords. */
|
||||
_max_selchars_length = _key_positions.iterator(_max_key_len).remaining();
|
||||
|
||||
/* Check for duplicates, i.e. keywords with the same _selchars array
|
||||
(and - if !option[NOLENGTH] - also the same length).
|
||||
We deal with these by building an equivalence class, so that only
|
||||
@@ -768,42 +773,8 @@ Search::prepare ()
|
||||
|
||||
/* Memory allocation. */
|
||||
_asso_values = new int[_alpha_size];
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
|
||||
/* Returns the length of keyword list. */
|
||||
|
||||
int
|
||||
Search::keyword_list_length () const
|
||||
{
|
||||
return _list_len;
|
||||
}
|
||||
|
||||
/* Returns the maximum length of keywords. */
|
||||
|
||||
int
|
||||
Search::max_key_length () const
|
||||
{
|
||||
return _max_key_len;
|
||||
}
|
||||
|
||||
/* Returns the number of key positions. */
|
||||
|
||||
int
|
||||
Search::get_max_keysig_size () const
|
||||
{
|
||||
return _key_positions.is_useall() ? _max_key_len : _key_positions.get_size();
|
||||
}
|
||||
|
||||
/* ---------------------- Finding good asso_values[] ----------------------- */
|
||||
|
||||
/* Initializes the asso_values[] related parameters. */
|
||||
|
||||
void
|
||||
Search::prepare_asso_values ()
|
||||
{
|
||||
int non_linked_length = keyword_list_length ();
|
||||
int non_linked_length = _list_len;
|
||||
unsigned int asso_value_max;
|
||||
|
||||
asso_value_max =
|
||||
@@ -824,8 +795,8 @@ Search::prepare_asso_values ()
|
||||
|
||||
/* Given the bound for _asso_values[c], we have a bound for the possible
|
||||
hash values, as computed in compute_hash(). */
|
||||
_max_hash_value = (option[NOLENGTH] ? 0 : max_key_length ())
|
||||
+ (_asso_value_max - 1) * get_max_keysig_size ();
|
||||
_max_hash_value = (option[NOLENGTH] ? 0 : _max_key_len)
|
||||
+ (_asso_value_max - 1) * _max_selchars_length;
|
||||
/* Allocate a sparse bit vector for detection of collisions of hash
|
||||
values. */
|
||||
_collision_detector = new Bool_Array (_max_hash_value + 1);
|
||||
@@ -1031,7 +1002,7 @@ Search::count_possible_collisions (EquivalenceClass *partition, unsigned int c)
|
||||
This leads to (|p|^2 - |p1|^2 - |p2|^2 - ...)/2 possible collisions.
|
||||
Return the sum of this expression over all equivalence classes. */
|
||||
unsigned int sum = 0;
|
||||
unsigned int m = get_max_keysig_size();
|
||||
unsigned int m = _max_selchars_length;
|
||||
unsigned int split_cardinalities[m+1];
|
||||
for (EquivalenceClass *cls = partition; cls; cls = cls->_next)
|
||||
{
|
||||
@@ -1383,8 +1354,8 @@ Search::find_asso_values ()
|
||||
_asso_value_max = step->_asso_value_max;
|
||||
/* Reinitialize _max_hash_value. */
|
||||
_max_hash_value =
|
||||
(option[NOLENGTH] ? 0 : max_key_length ())
|
||||
+ (_asso_value_max - 1) * get_max_keysig_size ();
|
||||
(option[NOLENGTH] ? 0 : _max_key_len)
|
||||
+ (_asso_value_max - 1) * _max_selchars_length;
|
||||
/* Reinitialize _collision_detector. */
|
||||
delete _collision_detector;
|
||||
_collision_detector =
|
||||
@@ -1459,7 +1430,6 @@ Search::compute_hash (KeywordExt *keyword) const
|
||||
void
|
||||
Search::find_good_asso_values ()
|
||||
{
|
||||
prepare ();
|
||||
prepare_asso_values ();
|
||||
|
||||
/* Search for good _asso_values[]. */
|
||||
@@ -1557,7 +1527,7 @@ void
|
||||
Search::optimize ()
|
||||
{
|
||||
/* Preparations. */
|
||||
preprepare ();
|
||||
prepare ();
|
||||
|
||||
/* Step 1: Finding good byte positions. */
|
||||
find_positions ();
|
||||
@@ -1633,7 +1603,7 @@ Search::~Search ()
|
||||
"\ntotal keywords = %d\ntotal duplicates = %d\nmaximum key length = %d\n",
|
||||
_list_len, _total_keys, _total_duplicates, _max_key_len);
|
||||
|
||||
int field_width = get_max_keysig_size ();
|
||||
int field_width = _max_selchars_length;
|
||||
fprintf (stderr, "\nList contents are:\n(hash value, key length, index, %*s, keyword):\n",
|
||||
field_width, "selchars");
|
||||
for (KeywordExt_List *ptr = _head; ptr; ptr = ptr->rest())
|
||||
|
||||
16
src/search.h
16
src/search.h
@@ -39,7 +39,7 @@ public:
|
||||
~Search ();
|
||||
void optimize ();
|
||||
private:
|
||||
void preprepare ();
|
||||
void prepare ();
|
||||
|
||||
/* Computes the upper bound on the indices passed to asso_values[],
|
||||
assuming no alpha_increments. */
|
||||
@@ -76,17 +76,6 @@ private:
|
||||
/* Find good _alpha_inc[]. */
|
||||
void find_alpha_inc ();
|
||||
|
||||
void prepare ();
|
||||
|
||||
/* Returns the length of keyword list. */
|
||||
int keyword_list_length () const;
|
||||
|
||||
/* Returns the maximum length of keywords. */
|
||||
int max_key_length () const;
|
||||
|
||||
/* Returns the number of key positions. */
|
||||
int get_max_keysig_size () const;
|
||||
|
||||
/* Initializes the asso_values[] related parameters. */
|
||||
void prepare_asso_values ();
|
||||
|
||||
@@ -136,6 +125,9 @@ public:
|
||||
upper case characters to lower case characters (and maybe more). */
|
||||
unsigned int * _alpha_unify;
|
||||
|
||||
/* Maximum _selchars_length over all keywords. */
|
||||
unsigned int _max_selchars_length;
|
||||
|
||||
/* Total number of duplicates that have been moved to _duplicate_link lists
|
||||
(not counting their representatives which stay on the main list). */
|
||||
int _total_duplicates;
|
||||
|
||||
Reference in New Issue
Block a user