diff options
author | Dom Lachowicz <domlachowicz@gmail.com> | 2006-04-02 14:01:47 +0000 |
---|---|---|
committer | Dom Lachowicz <domlachowicz@gmail.com> | 2006-04-02 14:01:47 +0000 |
commit | c31c99ef462a72977042c263fb3b0849f62e750b (patch) | |
tree | 6976697f41463b17cc227f95d9a87dd69ed4474f /src | |
parent | d766a8dc85b962ccf110f9454549013070914e13 (diff) | |
download | enchant-c31c99ef462a72977042c263fb3b0849f62e750b.tar.gz |
optimize dict_exists in (especially) the ispell backend
git-svn-id: svn+ssh://svn.abisource.com/svnroot/enchant/trunk@21125 bcba8976-2d24-0410-9c9c-aab3bd5fdfd6
Diffstat (limited to 'src')
-rw-r--r-- | src/hspell/hspell_provider.c | 11 | ||||
-rw-r--r-- | src/ispell/ispell_checker.cpp | 20 |
2 files changed, 30 insertions, 1 deletions
diff --git a/src/hspell/hspell_provider.c b/src/hspell/hspell_provider.c index ee01a2b..3cd09fa 100644 --- a/src/hspell/hspell_provider.c +++ b/src/hspell/hspell_provider.c @@ -228,7 +228,7 @@ static char ** hspell_provider_list_dicts (EnchantProvider * me, size_t * out_n_dicts) { - char * dictionary_path; + const char * dictionary_path; char ** out_list = NULL; *out_n_dicts = 0; @@ -246,6 +246,14 @@ hspell_provider_list_dicts (EnchantProvider * me, return out_list; } +static int +hspell_provider_dictionary_exists (struct str_enchant_provider * me, + const char *const tag) +{ + (void)me; + return (!strcmp ("he", tag) || !strcmp ("he_IL", tag)); +} + static void hspell_provider_free_string_list (EnchantProvider * me, char **str_list) { @@ -284,6 +292,7 @@ init_enchant_provider (void) provider->dispose = hspell_provider_dispose; provider->request_dict = hspell_provider_request_dict; provider->dispose_dict = hspell_provider_dispose_dict; + provider->dictionary_exists = hspell_provider_dictionary_exists; provider->identify = hspell_provider_identify; provider->describe = hspell_provider_describe; provider->list_dicts = hspell_provider_list_dicts; diff --git a/src/ispell/ispell_checker.cpp b/src/ispell/ispell_checker.cpp index e52d226..2155204 100644 --- a/src/ispell/ispell_checker.cpp +++ b/src/ispell/ispell_checker.cpp @@ -669,6 +669,25 @@ ispell_provider_list_dictionaries (EnchantProvider * me, return out_dicts; } +static int +ispell_provider_dictionary_exists (struct str_enchant_provider * me, + const char *const tag) +{ + std::string shortened_dict (tag); + size_t uscore_pos; + if ((uscore_pos = shortened_dict.rfind ('_')) != ((size_t)-1)) + shortened_dict = shortened_dict.substr(0, uscore_pos); + + for (size_t i = 0; i < size_ispell_map; i++) + { + const IspellMap * mapping = (const IspellMap *)(&(ispell_map[i])); + if (!strcmp (tag, mapping->lang) || !strcmp (shortened_dict.c_str(), mapping->lang)) + return _ispell_provider_dictionary_exists(me, mapping->dict); + } + + return 0; +} + static void ispell_provider_free_string_list (EnchantProvider * me, char **str_list) { @@ -704,6 +723,7 @@ init_enchant_provider (void) provider->dispose = ispell_provider_dispose; provider->request_dict = ispell_provider_request_dict; provider->dispose_dict = ispell_provider_dispose_dict; + provider->dictionary_exists = ispell_provider_dictionary_exists; provider->identify = ispell_provider_identify; provider->describe = ispell_provider_describe; provider->list_dicts = ispell_provider_list_dictionaries; |