summaryrefslogtreecommitdiffstats
path: root/chrome/browser/history/query_parser.cc
diff options
context:
space:
mode:
authorsky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-05-19 03:59:42 +0000
committersky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-05-19 03:59:42 +0000
commit85d911cd2f9cf2cb8235ff46560b5931ef5ab16e (patch)
treec8b776f8cd9f2d42f093ba02fc15e81b513532a6 /chrome/browser/history/query_parser.cc
parentc12c168662aeed170eea3a9d401616c6db522ecb (diff)
downloadchromium_src-85d911cd2f9cf2cb8235ff46560b5931ef5ab16e.zip
chromium_src-85d911cd2f9cf2cb8235ff46560b5931ef5ab16e.tar.gz
chromium_src-85d911cd2f9cf2cb8235ff46560b5931ef5ab16e.tar.bz2
Adds an index over bookmark titles for fast look up.
The index is currently built on the main thread (because that's where we do the decoding now), but I'll change that after landing this. BUG=6646 TEST=There are tests to cover this, but make sure the omnibox still suggests bookmark titles. Review URL: http://codereview.chromium.org/115403 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@16357 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/history/query_parser.cc')
-rw-r--r--chrome/browser/history/query_parser.cc35
1 files changed, 14 insertions, 21 deletions
diff --git a/chrome/browser/history/query_parser.cc b/chrome/browser/history/query_parser.cc
index 39754ce..f3c4063 100644
--- a/chrome/browser/history/query_parser.cc
+++ b/chrome/browser/history/query_parser.cc
@@ -56,25 +56,6 @@ void CoalseAndSortMatchPositions(Snippet::MatchPositions* matches) {
CoalesceMatchesFrom(i, matches);
}
-// For CJK ideographs and Korean Hangul, even a single character
-// can be useful in prefix matching, but that may give us too many
-// false positives. Moreover, the current ICU word breaker gives us
-// back every single Chinese character as a word so that there's no
-// point doing anything for them and we only adjust the minimum length
-// to 2 for Korean Hangul while using 3 for others. This is a temporary
-// hack until we have a segmentation support.
-inline bool IsWordLongEnoughForPrefixSearch(const std::wstring& word)
-{
- DCHECK(word.size() > 0);
- size_t minimum_length = 3;
- // We intentionally exclude Hangul Jamos (both Conjoining and compatibility)
- // because they 'behave like' Latin letters. Moreover, we should
- // normalize the former before reaching here.
- if (0xAC00 <= word[0] && word[0] <= 0xD7A3)
- minimum_length = 2;
- return word.size() >= minimum_length;
-}
-
} // namespace
// Inheritance structure:
@@ -119,7 +100,7 @@ bool QueryNodeWord::HasMatchIn(const std::vector<QueryWord>& words,
}
bool QueryNodeWord::Matches(const std::wstring& word, bool exact) const {
- if (exact || !IsWordLongEnoughForPrefixSearch(word_))
+ if (exact || !QueryParser::IsWordLongEnoughForPrefixSearch(word_))
return word == word_;
return word.size() >= word_.size() &&
(word_.compare(0, word_.size(), word, 0, word_.size()) == 0);
@@ -133,7 +114,7 @@ int QueryNodeWord::AppendToSQLiteQuery(std::wstring* query) const {
query->append(word_);
// Use prefix search if we're not literal and long enough.
- if (!literal_ && IsWordLongEnoughForPrefixSearch(word_))
+ if (!literal_ && QueryParser::IsWordLongEnoughForPrefixSearch(word_))
*query += L'*';
return 1;
}
@@ -260,6 +241,18 @@ bool QueryNodePhrase::HasMatchIn(
QueryParser::QueryParser() {
}
+// static
+bool QueryParser::IsWordLongEnoughForPrefixSearch(const std::wstring& word) {
+ DCHECK(word.size() > 0);
+ size_t minimum_length = 3;
+ // We intentionally exclude Hangul Jamos (both Conjoining and compatibility)
+ // because they 'behave like' Latin letters. Moreover, we should
+ // normalize the former before reaching here.
+ if (0xAC00 <= word[0] && word[0] <= 0xD7A3)
+ minimum_length = 2;
+ return word.size() >= minimum_length;
+}
+
// Returns true if the character is considered a quote.
static bool IsQueryQuote(wchar_t ch) {
return ch == '"' ||