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

Side by Side Diff: components/query_parser/snippet.cc

Issue 2781263002: Some C++11 cleanup of history types. (Closed)
Patch Set: Fix Android Created 3 years, 8 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 unified diff | Download patch
« no previous file with comments | « components/query_parser/snippet.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "components/query_parser/snippet.h" 5 #include "components/query_parser/snippet.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <memory> 10 #include <memory>
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after
203 static_cast<int32_t>(i->second), 203 static_cast<int32_t>(i->second),
204 &utf8_pos, &utf16_pos); 204 &utf8_pos, &utf16_pos);
205 } 205 }
206 } 206 }
207 207
208 Snippet::Snippet() { 208 Snippet::Snippet() {
209 } 209 }
210 210
211 Snippet::Snippet(const Snippet& other) = default; 211 Snippet::Snippet(const Snippet& other) = default;
212 212
213 // TODO(bug 706963) this should be implemented as "= default" when Android
214 // toolchain is updated.
215 Snippet::Snippet(Snippet&& other) noexcept
216 : text_(std::move(other.text_)), matches_(std::move(other.matches_)) {}
217
213 Snippet::~Snippet() { 218 Snippet::~Snippet() {
214 } 219 }
215 220
221 Snippet& Snippet::operator=(const Snippet&) = default;
222
216 void Snippet::ComputeSnippet(const MatchPositions& match_positions, 223 void Snippet::ComputeSnippet(const MatchPositions& match_positions,
217 const std::string& document) { 224 const std::string& document) {
218 // The length of snippets we try to produce. 225 // The length of snippets we try to produce.
219 // We can generate longer snippets but stop once we cross kSnippetMaxLength. 226 // We can generate longer snippets but stop once we cross kSnippetMaxLength.
220 const size_t kSnippetMaxLength = 200; 227 const size_t kSnippetMaxLength = 200;
221 const base::string16 kEllipsis = base::ASCIIToUTF16(" ... "); 228 const base::string16 kEllipsis = base::ASCIIToUTF16(" ... ");
222 229
223 UText* document_utext = NULL; 230 UText* document_utext = NULL;
224 UErrorCode status = U_ZERO_ERROR; 231 UErrorCode status = U_ZERO_ERROR;
225 document_utext = utext_openUTF8(document_utext, document.data(), 232 document_utext = utext_openUTF8(document_utext, document.data(),
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
298 utext_close(document_utext); 305 utext_close(document_utext);
299 swap(text_, snippet); 306 swap(text_, snippet);
300 } 307 }
301 308
302 void Snippet::Swap(Snippet* other) { 309 void Snippet::Swap(Snippet* other) {
303 text_.swap(other->text_); 310 text_.swap(other->text_);
304 matches_.swap(other->matches_); 311 matches_.swap(other->matches_);
305 } 312 }
306 313
307 } // namespace query_parser 314 } // namespace query_parser
OLDNEW
« no previous file with comments | « components/query_parser/snippet.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698