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

Side by Side Diff: chrome/profiling/stack.cc

Issue 2943733002: Add out-of-process memory logging stream parsing. (Closed)
Patch Set: Remove version Created 3 years, 6 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
(Empty)
1 // Copyright 2017 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "chrome/profiling/stack.h"
6
7 #include <algorithm>
8
9 #include "base/hash.h"
10 #include "chrome/profiling/profiling_globals.h"
11 #include "chrome/profiling/stack_storage.h"
12
13 namespace profiling {
14
15 namespace {
16
17 size_t ComputeHash(const std::vector<Address>& addrs) {
18 if (addrs.empty())
19 return 0;
20 // Assume Address is a POD containing only the address with no padding.
21 return base::Hash(reinterpret_cast<const char*>(&addrs[0]),
22 addrs.size() * sizeof(Address));
23 }
24
25 } // namespace
26
27 Stack::Stack(std::vector<Address>&& a)
28 : addrs_(std::move(a)), hash_(ComputeHash(addrs_)) {}
29
30 Stack::~Stack() {}
31
32 bool Stack::operator==(const Stack& other) const {
33 if (addrs_.size() != other.addrs_.size())
Boris Vidolov 2017/06/17 03:13:15 Why not compare hash_ first and do the expensive o
brettw 2017/06/19 23:29:46 The answer to both of these is that the only time
34 return false;
35 for (size_t i = 0; i < addrs_.size(); i++) {
36 if (addrs_[i] != other.addrs_[i])
Boris Vidolov 2017/06/17 03:13:15 I know that operator != is overridden, but I am st
brettw 2017/06/19 23:29:46 I switched to memcmp.
37 return false;
38 }
39 return true;
40 }
41
42 bool Stack::operator!=(const Stack& other) const {
43 return !operator==(other);
44 }
45
46 } // namespace profiling
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698