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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: chrome/profiling/stack.cc
diff --git a/chrome/profiling/stack.cc b/chrome/profiling/stack.cc
new file mode 100644
index 0000000000000000000000000000000000000000..5715177e1a1a60d0616b84b52f15c6d5bcd95bb2
--- /dev/null
+++ b/chrome/profiling/stack.cc
@@ -0,0 +1,46 @@
+// Copyright 2017 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/profiling/stack.h"
+
+#include <algorithm>
+
+#include "base/hash.h"
+#include "chrome/profiling/profiling_globals.h"
+#include "chrome/profiling/stack_storage.h"
+
+namespace profiling {
+
+namespace {
+
+size_t ComputeHash(const std::vector<Address>& addrs) {
+ if (addrs.empty())
+ return 0;
+ // Assume Address is a POD containing only the address with no padding.
+ return base::Hash(reinterpret_cast<const char*>(&addrs[0]),
+ addrs.size() * sizeof(Address));
+}
+
+} // namespace
+
+Stack::Stack(std::vector<Address>&& a)
+ : addrs_(std::move(a)), hash_(ComputeHash(addrs_)) {}
+
+Stack::~Stack() {}
+
+bool Stack::operator==(const Stack& other) const {
+ 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
+ return false;
+ for (size_t i = 0; i < addrs_.size(); i++) {
+ 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.
+ return false;
+ }
+ return true;
+}
+
+bool Stack::operator!=(const Stack& other) const {
+ return !operator==(other);
+}
+
+} // namespace profiling

Powered by Google App Engine
This is Rietveld 408576698