summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorpkasting@chromium.org <pkasting@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-08-31 21:05:48 +0000
committerpkasting@chromium.org <pkasting@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-08-31 21:05:48 +0000
commit9e1800753fe8be454d23d2ac24e84f238645d3f7 (patch)
treec318f5892d9801039b27802c2bd273b3991d8b5d
parent42cd4c3c6243cff6e6c665e83c552d28d6a1665c (diff)
downloadchromium_src-9e1800753fe8be454d23d2ac24e84f238645d3f7.zip
chromium_src-9e1800753fe8be454d23d2ac24e84f238645d3f7.tar.gz
chromium_src-9e1800753fe8be454d23d2ac24e84f238645d3f7.tar.bz2
Remove a static initializer in the HQP.
BUG=94925 TEST=none Review URL: http://codereview.chromium.org/7740071 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@99036 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/autocomplete/history_quick_provider.cc9
-rw-r--r--chrome/browser/autocomplete/history_quick_provider.h3
-rw-r--r--chrome/browser/autocomplete/history_quick_provider_unittest.cc39
3 files changed, 23 insertions, 28 deletions
diff --git a/chrome/browser/autocomplete/history_quick_provider.cc b/chrome/browser/autocomplete/history_quick_provider.cc
index d1ac04c..8a96c52 100644
--- a/chrome/browser/autocomplete/history_quick_provider.cc
+++ b/chrome/browser/autocomplete/history_quick_provider.cc
@@ -110,7 +110,7 @@ void HistoryQuickProvider::DoAutocomplete() {
// |max_match_score|. Upon use of |max_match_score| it is decremented.
// All subsequent matches must be clamped to retain match results ordering.
int max_match_score = autocomplete_input_.prevent_inline_autocomplete() ?
- kMaxNonInliningScore : -1;
+ (AutocompleteResult::kLowestDefaultScore - 1) : -1;
for (ScoredHistoryMatches::const_iterator match_iter = matches.begin();
match_iter != matches.end(); ++match_iter) {
const ScoredHistoryMatch& history_match(*match_iter);
@@ -126,10 +126,6 @@ void HistoryQuickProvider::DoAutocomplete() {
}
}
-// static
-const int HistoryQuickProvider::kMaxNonInliningScore =
- AutocompleteResult::kLowestDefaultScore - 1;
-
AutocompleteMatch HistoryQuickProvider::QuickMatchToACMatch(
const ScoredHistoryMatch& history_match,
const ScoredHistoryMatches& history_matches,
@@ -202,7 +198,8 @@ int HistoryQuickProvider::CalculateRelevance(
// at the beginning of the result's URL and there is exactly one substring
// match in the URL.
int score = (history_match.can_inline) ? history_match.raw_score :
- std::min(kMaxNonInliningScore, history_match.raw_score);
+ std::min(AutocompleteResult::kLowestDefaultScore - 1,
+ history_match.raw_score);
*max_match_score = ((*max_match_score < 0) ?
score : std::min(score, *max_match_score)) - 1;
return *max_match_score + 1;
diff --git a/chrome/browser/autocomplete/history_quick_provider.h b/chrome/browser/autocomplete/history_quick_provider.h
index 8f581c3..e6bb353 100644
--- a/chrome/browser/autocomplete/history_quick_provider.h
+++ b/chrome/browser/autocomplete/history_quick_provider.h
@@ -52,9 +52,6 @@ class HistoryQuickProvider : public HistoryProvider {
FRIEND_TEST_ALL_PREFIXES(HistoryQuickProviderTest, Spans);
FRIEND_TEST_ALL_PREFIXES(HistoryQuickProviderTest, Relevance);
- // The initial maximum allowable score for a match which cannot be inlined.
- static const int kMaxNonInliningScore;
-
// Creates an AutocompleteMatch from |history_match|. |max_match_score| gives
// the maximum possible score for the match. |history_matches| is the full set
// of matches to compare each match to when calculating confidence.
diff --git a/chrome/browser/autocomplete/history_quick_provider_unittest.cc b/chrome/browser/autocomplete/history_quick_provider_unittest.cc
index 021efb7..f936860 100644
--- a/chrome/browser/autocomplete/history_quick_provider_unittest.cc
+++ b/chrome/browser/autocomplete/history_quick_provider_unittest.cc
@@ -377,49 +377,50 @@ TEST_F(HistoryQuickProviderTest, Relevance) {
next_score = 1500;
match.raw_score = 1425;
match.can_inline = false;
+ const int kMaxNonInliningScore = AutocompleteResult::kLowestDefaultScore - 1;
EXPECT_EQ(HistoryQuickProvider::CalculateRelevance(match, &next_score),
- HistoryQuickProvider::kMaxNonInliningScore);
- EXPECT_EQ(next_score, HistoryQuickProvider::kMaxNonInliningScore - 1);
+ kMaxNonInliningScore);
+ EXPECT_EQ(next_score, kMaxNonInliningScore - 1);
// Can inline, clamped.
- next_score = HistoryQuickProvider::kMaxNonInliningScore;
+ next_score = kMaxNonInliningScore;
match.raw_score = 1425;
match.can_inline = true;
EXPECT_EQ(HistoryQuickProvider::CalculateRelevance(match, &next_score),
- HistoryQuickProvider::kMaxNonInliningScore);
- EXPECT_EQ(next_score, HistoryQuickProvider::kMaxNonInliningScore - 1);
+ kMaxNonInliningScore);
+ EXPECT_EQ(next_score, kMaxNonInliningScore - 1);
// Can't inline, clamped.
- next_score = HistoryQuickProvider::kMaxNonInliningScore;
+ next_score = kMaxNonInliningScore;
match.raw_score = 1425;
match.can_inline = false;
EXPECT_EQ(HistoryQuickProvider::CalculateRelevance(match, &next_score),
- HistoryQuickProvider::kMaxNonInliningScore);
- EXPECT_EQ(next_score, HistoryQuickProvider::kMaxNonInliningScore - 1);
+ kMaxNonInliningScore);
+ EXPECT_EQ(next_score, kMaxNonInliningScore - 1);
// Score just above the clamped limit.
- next_score = HistoryQuickProvider::kMaxNonInliningScore;
+ next_score = kMaxNonInliningScore;
match.raw_score = AutocompleteResult::kLowestDefaultScore;
match.can_inline = false;
EXPECT_EQ(HistoryQuickProvider::CalculateRelevance(match, &next_score),
- HistoryQuickProvider::kMaxNonInliningScore);
- EXPECT_EQ(next_score, HistoryQuickProvider::kMaxNonInliningScore - 1);
+ kMaxNonInliningScore);
+ EXPECT_EQ(next_score, kMaxNonInliningScore - 1);
// Score right at the clamped limit.
- next_score = HistoryQuickProvider::kMaxNonInliningScore;
- match.raw_score = HistoryQuickProvider::kMaxNonInliningScore;
+ next_score = kMaxNonInliningScore;
+ match.raw_score = kMaxNonInliningScore;
match.can_inline = true;
EXPECT_EQ(HistoryQuickProvider::CalculateRelevance(match, &next_score),
- HistoryQuickProvider::kMaxNonInliningScore);
- EXPECT_EQ(next_score, HistoryQuickProvider::kMaxNonInliningScore - 1);
+ kMaxNonInliningScore);
+ EXPECT_EQ(next_score, kMaxNonInliningScore - 1);
// Score just below the clamped limit.
- next_score = HistoryQuickProvider::kMaxNonInliningScore;
- match.raw_score = HistoryQuickProvider::kMaxNonInliningScore - 1;
+ next_score = kMaxNonInliningScore;
+ match.raw_score = kMaxNonInliningScore - 1;
match.can_inline = true;
EXPECT_EQ(HistoryQuickProvider::CalculateRelevance(match, &next_score),
- HistoryQuickProvider::kMaxNonInliningScore - 1);
- EXPECT_EQ(next_score, HistoryQuickProvider::kMaxNonInliningScore - 2);
+ kMaxNonInliningScore - 1);
+ EXPECT_EQ(next_score, kMaxNonInliningScore - 2);
// Low score, can inline, not clamped.
next_score = 1500;