Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3205)

Unified Diff: base/i18n/string_search.h

Issue 18031015: base/i18n: Class for efficiently searching the same query over many texts. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address review comments (#5) Created 7 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | base/i18n/string_search.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/i18n/string_search.h
diff --git a/base/i18n/string_search.h b/base/i18n/string_search.h
index 9d18631039831acbb30850f3cdcd8393899b9501..138606f8c60c3fceaa1c70b2746e26e7f3a10b29 100644
--- a/base/i18n/string_search.h
+++ b/base/i18n/string_search.h
@@ -8,6 +8,8 @@
#include "base/i18n/base_i18n_export.h"
#include "base/strings/string16.h"
+struct UStringSearch;
+
namespace base {
namespace i18n {
@@ -24,6 +26,27 @@ BASE_I18N_EXPORT
size_t* match_index,
size_t* match_length);
+// This class is for speeding up multiple StringSearchIgnoringCaseAndAccents()
+// with the same |find_this| argument. |find_this| is passed as the constructor
+// argument, and precomputation for searching is done only at that timing.
+class BASE_I18N_EXPORT FixedPatternStringSearchIgnoringCaseAndAccents {
+ public:
+ explicit FixedPatternStringSearchIgnoringCaseAndAccents(
+ const string16& find_this);
+ ~FixedPatternStringSearchIgnoringCaseAndAccents();
+
+ // Returns true if |in_this| contains |find_this|. If |match_index| or
+ // |match_length| are non-NULL, they are assigned the start position and total
+ // length of the match.
+ bool Search(const string16& in_this,
+ size_t* match_index,
+ size_t* match_length);
+
+ private:
+ string16 find_this_;
+ UStringSearch* search_;
+};
+
} // namespace i18n
} // namespace base
« no previous file with comments | « no previous file | base/i18n/string_search.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698