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

Unified Diff: ipc/brokerable_attachment.h

Issue 1451173002: IPC: Use <algorithm> helpers for comparing arrays (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 1 month 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ipc/brokerable_attachment.h
diff --git a/ipc/brokerable_attachment.h b/ipc/brokerable_attachment.h
index ce3082cd92b8986557d9245f5799567feb22aa06..6761f22a7126daf5875e7fdfa44238e5508042b4 100644
--- a/ipc/brokerable_attachment.h
+++ b/ipc/brokerable_attachment.h
@@ -7,6 +7,8 @@
#include <stdint.h>
+#include <algorithm>
+
#include "base/macros.h"
#include "ipc/ipc_export.h"
#include "ipc/ipc_message_attachment.h"
@@ -37,21 +39,12 @@ class IPC_EXPORT BrokerableAttachment : public MessageAttachment {
void SerializeToBuffer(char* start_address, size_t size);
bool operator==(const AttachmentId& rhs) const {
- for (size_t i = 0; i < kNonceSize; ++i) {
- if (nonce[i] != rhs.nonce[i])
- return false;
- }
- return true;
+ return std::equal(nonce, nonce + kNonceSize, rhs.nonce);
}
bool operator<(const AttachmentId& rhs) const {
- for (size_t i = 0; i < kNonceSize; ++i) {
- if (nonce[i] < rhs.nonce[i])
- return true;
- if (nonce[i] > rhs.nonce[i])
- return false;
- }
- return false;
+ return std::lexicographical_compare(nonce, nonce + kNonceSize, rhs.nonce,
+ rhs.nonce + kNonceSize);
}
};
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698