summaryrefslogtreecommitdiff
path: root/src/ispell/ispell_checker.cpp
diff options
context:
space:
mode:
authorDom Lachowicz <domlachowicz@gmail.com>2006-04-02 14:01:47 +0000
committerDom Lachowicz <domlachowicz@gmail.com>2006-04-02 14:01:47 +0000
commitc31c99ef462a72977042c263fb3b0849f62e750b (patch)
tree6976697f41463b17cc227f95d9a87dd69ed4474f /src/ispell/ispell_checker.cpp
parentd766a8dc85b962ccf110f9454549013070914e13 (diff)
downloadenchant-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/ispell/ispell_checker.cpp')
-rw-r--r--src/ispell/ispell_checker.cpp20
1 files changed, 20 insertions, 0 deletions
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;