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

Side by Side Diff: components/safe_browsing_db/prefix_set.cc

Issue 1548203002: Convert Pass()→std::move() in //components/[n-z]* (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix bad headers Created 4 years, 12 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/safe_browsing_db/prefix_set.h" 5 #include "components/safe_browsing_db/prefix_set.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <utility>
8 9
9 #include "base/files/file_util.h" 10 #include "base/files/file_util.h"
10 #include "base/files/scoped_file.h" 11 #include "base/files/scoped_file.h"
11 #include "base/logging.h" 12 #include "base/logging.h"
12 #include "base/md5.h" 13 #include "base/md5.h"
13 #include "base/metrics/histogram.h" 14 #include "base/metrics/histogram.h"
14 #include "base/metrics/sparse_histogram.h" 15 #include "base/metrics/sparse_histogram.h"
15 16
16 namespace safe_browsing { 17 namespace safe_browsing {
17 18
(...skipping 365 matching lines...) Expand 10 before | Expand all | Expand 10 after
383 } 384 }
384 385
385 // Precisely size |index_| for read-only. It's 50k-60k, so minor savings, but 386 // Precisely size |index_| for read-only. It's 50k-60k, so minor savings, but
386 // they're almost free. 387 // they're almost free.
387 PrefixSet::IndexVector(prefix_set_->index_).swap(prefix_set_->index_); 388 PrefixSet::IndexVector(prefix_set_->index_).swap(prefix_set_->index_);
388 389
389 prefix_set_->full_hashes_ = hashes; 390 prefix_set_->full_hashes_ = hashes;
390 std::sort(prefix_set_->full_hashes_.begin(), prefix_set_->full_hashes_.end(), 391 std::sort(prefix_set_->full_hashes_.begin(), prefix_set_->full_hashes_.end(),
391 SBFullHashLess); 392 SBFullHashLess);
392 393
393 return prefix_set_.Pass(); 394 return std::move(prefix_set_);
394 } 395 }
395 396
396 scoped_ptr<const PrefixSet> PrefixSetBuilder::GetPrefixSetNoHashes() { 397 scoped_ptr<const PrefixSet> PrefixSetBuilder::GetPrefixSetNoHashes() {
397 return GetPrefixSet(std::vector<SBFullHash>()).Pass(); 398 return GetPrefixSet(std::vector<SBFullHash>());
398 } 399 }
399 400
400 void PrefixSetBuilder::EmitRun() { 401 void PrefixSetBuilder::EmitRun() {
401 DCHECK(prefix_set_.get()); 402 DCHECK(prefix_set_.get());
402 403
403 SBPrefix prev_prefix = buffer_[0]; 404 SBPrefix prev_prefix = buffer_[0];
404 uint16_t run[PrefixSet::kMaxRun]; 405 uint16_t run[PrefixSet::kMaxRun];
405 size_t run_pos = 0; 406 size_t run_pos = 0;
406 407
407 size_t i; 408 size_t i;
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
441 } 442 }
442 buffer_.push_back(prefix); 443 buffer_.push_back(prefix);
443 444
444 // Flush buffer when a run can be constructed. +1 for the index item, and +1 445 // Flush buffer when a run can be constructed. +1 for the index item, and +1
445 // to leave at least one item in the buffer for dropping duplicates. 446 // to leave at least one item in the buffer for dropping duplicates.
446 if (buffer_.size() > PrefixSet::kMaxRun + 2) 447 if (buffer_.size() > PrefixSet::kMaxRun + 2)
447 EmitRun(); 448 EmitRun();
448 } 449 }
449 450
450 } // namespace safe_browsing 451 } // namespace safe_browsing
OLDNEW
« no previous file with comments | « components/resource_provider/resource_provider_impl.cc ('k') | components/safe_json/safe_json_parser_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698