| OLD | NEW |
| (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()) |
| 34 return false; |
| 35 for (size_t i = 0; i < addrs_.size(); i++) { |
| 36 if (addrs_[i] != other.addrs_[i]) |
| 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 |
| OLD | NEW |