diff --git a/ChangeLog b/ChangeLog index d54f9e3992cbcd96b6969c015bdb7bc53962badf..314ffeaf7a43be55628b48f13d0f6a4653c4c605 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,16 @@ +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. diff --git a/src/libraries/libcommon/parser.c b/src/libraries/libcommon/parser.c index 4ce423e893a13ec5f16521af8a181ed2039ab577..57b58d0ac49c6b158100a34084ada8ea36a4fd0b 100644 --- a/src/libraries/libcommon/parser.c +++ b/src/libraries/libcommon/parser.c @@ -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. diff --git a/src/libraries/libcommon/parser.h b/src/libraries/libcommon/parser.h index 9a0808e274345dd128627d9fc8d4a3ee407aeb5c..66116a959dfbc1e122fbb2d7fe927d0ecaaaac8f 100644 --- a/src/libraries/libcommon/parser.h +++ b/src/libraries/libcommon/parser.h @@ -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; diff --git a/src/server/simple-cache.c b/src/server/simple-cache.c index 4194cd08f0dc24d0f6f864124dc4570ab556e98d..b75ac12d81de6ef65dcbda0b54c136a89b3b61be 100644 --- a/src/server/simple-cache.c +++ b/src/server/simple-cache.c @@ -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;