Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/history/snippet.h" | 5 #include "chrome/browser/history/snippet.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/scoped_ptr.h" | 10 #include "base/scoped_ptr.h" |
| (...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 143 // that it's within a window in terms of graphemes as well. | 143 // that it's within a window in terms of graphemes as well. |
| 144 if (next_match_start < previous_match_end + kSnippetContext) | 144 if (next_match_start < previous_match_end + kSnippetContext) |
| 145 return true; | 145 return true; |
| 146 bi->isBoundary(previous_match_end); | 146 bi->isBoundary(previous_match_end); |
| 147 // An alternative to this is to call |bi->next()| at most | 147 // An alternative to this is to call |bi->next()| at most |
| 148 // kSnippetContext times, compare |bi->current()| with |next_match_start| | 148 // kSnippetContext times, compare |bi->current()| with |next_match_start| |
| 149 // after each call and return early if possible. There are other | 149 // after each call and return early if possible. There are other |
| 150 // heuristics to speed things up if necessary, but it's not likely that | 150 // heuristics to speed things up if necessary, but it's not likely that |
| 151 // we need to bother. | 151 // we need to bother. |
| 152 bi->next(kSnippetContext); | 152 bi->next(kSnippetContext); |
| 153 int64_t current = bi->current(); | 153 int64 current = bi->current(); |
| 154 return (next_match_start < current || current == BreakIterator::DONE); | 154 return (next_match_start < static_cast<uint64>(current) || |
|
Evan Martin
2009/07/28 21:15:29
this looks suspicious for 32-bit. but all of this
| |
| 155 current == BreakIterator::DONE); | |
| 155 } | 156 } |
| 156 | 157 |
| 157 } // namespace | 158 } // namespace |
| 158 | 159 |
| 159 // static | 160 // static |
| 160 void Snippet::ExtractMatchPositions(const std::string& offsets_str, | 161 void Snippet::ExtractMatchPositions(const std::string& offsets_str, |
| 161 const std::string& column_num, | 162 const std::string& column_num, |
| 162 MatchPositions* match_positions) { | 163 MatchPositions* match_positions) { |
| 163 DCHECK(match_positions); | 164 DCHECK(match_positions); |
| 164 if (offsets_str.empty()) | 165 if (offsets_str.empty()) |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 260 start = end; | 261 start = end; |
| 261 | 262 |
| 262 // Stop here if we have enough snippet computed. | 263 // Stop here if we have enough snippet computed. |
| 263 if (snippet.size() >= kSnippetMaxLength) | 264 if (snippet.size() >= kSnippetMaxLength) |
| 264 break; | 265 break; |
| 265 } | 266 } |
| 266 | 267 |
| 267 utext_close(document_utext); | 268 utext_close(document_utext); |
| 268 swap(text_, snippet); | 269 swap(text_, snippet); |
| 269 } | 270 } |
| OLD | NEW |