Speed up finding message catalog by name in wxTranslations.

Use a helper hash map to allow efficiently finding message catalogs by name
instead of using linear search in a linked list which can be noticeably slow
when many catalogs are used.

This speeds up wxGetTranslation() when the domain is specified.

Closes #16975.
This commit is contained in:
Tomas Rapkauskas
2015-05-01 20:36:08 +03:00
committed by Vadim Zeitlin
parent d1de0f3038
commit 97286e13bd
2 changed files with 11 additions and 9 deletions

View File

@@ -183,6 +183,12 @@ private:
wxTranslationsLoader *m_loader;
wxMsgCatalog *m_pMsgCat; // pointer to linked list of catalogs
// In addition to keeping all the catalogs in the linked list, we also
// store them in a hash map indexed by the domain name to allow finding
// them by name efficiently.
WX_DECLARE_HASH_MAP(wxString, wxMsgCatalog *, wxStringHash, wxStringEqual, wxMsgCatalogMap);
wxMsgCatalogMap m_catalogMap;
};