Commit 55499424 authored by Per Cederqvist's avatar Per Cederqvist

Simplified the name parsing routing, and save some small amount of

memory, by removing the priority field of Matching_info.
* src/libraries/libcommon/parser.c (parse): Don't let the priority
influence the match.  The priority functionality was poorly
documented, not used by lyskomd, and made the code more complex.
* src/libraries/libcommon/parser.h (Matching_info): Removed the
priority field, which is no longer used.
* src/server/simple-cache.c (rebuild_matching_info_entry): Don't
initialize the priority field.
(build_matching_info): Ditto.
parent c8c248e0
2005-12-27 Per Cederqvist <ceder@lysator.liu.se>
Simplified the name parsing routing, and save some small amount of
memory, by removing the priority field of Matching_info.
* src/libraries/libcommon/parser.c (parse): Don't let the priority
influence the match. The priority functionality was poorly
documented, not used by lyskomd, and made the code more complex.
* src/libraries/libcommon/parser.h (Matching_info): Removed the
priority field, which is no longer used.
* src/server/simple-cache.c (rebuild_matching_info_entry): Don't
initialize the priority field.
(build_matching_info): Ditto.
2005-12-25 Per Cederqvist <ceder@lysator.liu.se>
Minor code cleanup.
......
......@@ -319,7 +319,6 @@ parse (String source_string,
int no_of_source_words;
int first_non_matching;
int best_match;
int highest_priority;
const int chunk_size = 20;
......@@ -356,7 +355,6 @@ parse (String source_string,
size_of_index_list = 0;
index = -1;
best_match = 1; /* At least one word */
highest_priority = 1;
while (match_table[++index].conf_no != 0)
{
if (s_empty (match_table[index].name))
......@@ -376,17 +374,11 @@ parse (String source_string,
if (first_non_matching < best_match)
continue; /* Try next entry in table */
if ( first_non_matching == best_match
&& highest_priority > match_table[index].priority)
continue;
/* If we reach this far, then we have a match that should be
* inserted in the table. But if it is a better match than any
* before, then we clear the table first. */
if ( first_non_matching > best_match
|| match_table[index].priority > highest_priority)
if ( first_non_matching > best_match )
{
highest_priority = match_table[index].priority;
best_match = first_non_matching;
answer.no_of_matches = 0;
}
......@@ -411,7 +403,6 @@ parse (String source_string,
answer.indexes = temp_indexes;
}
highest_priority = match_table [index].priority;
answer.indexes[answer.no_of_matches] = index;
/* Find out where the arguments start.
* This value should not be used if more than one match is found.
......
......@@ -75,7 +75,6 @@ typedef struct matching_info {
Conf_no conf_no; /* Conference */
String name; /* Name to match against */
Parse_token * tokens; /* Tokenized version of name */
int priority; /* Normally in interval 1..15 */
} Matching_info;
......
......@@ -1536,7 +1536,6 @@ rebuild_matching_info_entry(Conf_no conf_no)
*/
mtch->name = EMPTY_STRING;
mtch->tokens = NULL;
mtch->priority = 0;
}
}
else
......@@ -1588,7 +1587,6 @@ rebuild_matching_info_entry(Conf_no conf_no)
match_table[no_of_match_info].name = small_conf_arr[conf_no]->name;
match_table[no_of_match_info].tokens = tokenize(small_conf_arr[conf_no]->name,
s_fcrea_str(WHITESPACE));
match_table[no_of_match_info].priority = 7;
match_table[no_of_match_info].conf_no = conf_no;
/* Bump the number of match infos and enter the ending dummy */
......@@ -1596,7 +1594,6 @@ rebuild_matching_info_entry(Conf_no conf_no)
no_of_match_info += 1;
match_table[no_of_match_info].name = EMPTY_STRING;
match_table[no_of_match_info].tokens = NULL;
match_table[no_of_match_info].priority = 0;
match_table[no_of_match_info].conf_no = 0;
}
......@@ -1625,7 +1622,6 @@ build_matching_info(void)
{
mtch->name = small_conf_arr[ i ]->name;
mtch->tokens = tokenize(mtch->name, s_fcrea_str(WHITESPACE));
mtch->priority = 7;
mtch->conf_no = i;
++mtch;
++conf;
......@@ -1635,7 +1631,6 @@ build_matching_info(void)
mtch->name = EMPTY_STRING;
mtch->tokens = NULL;
mtch->priority = 0;
mtch->conf_no = 0;
return OK;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment