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

Unified Diff: ipc/ipc_message_utils.cc

Issue 39363002: Optimize ParamTraits<float> and ParamTraits<double> (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 7 years, 2 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
« no previous file with comments | « ipc/ipc_message_utils.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ipc/ipc_message_utils.cc
diff --git a/ipc/ipc_message_utils.cc b/ipc/ipc_message_utils.cc
index 2acddceb51c870752c58138779f4a4e4b6b01b61..c5ace243794805e06a5070b12a1afd67782d7ff1 100644
--- a/ipc/ipc_message_utils.cc
+++ b/ipc/ipc_message_utils.cc
@@ -311,37 +311,18 @@ void ParamTraits<unsigned long long>::Log(const param_type& p, std::string* l) {
l->append(base::Uint64ToString(p));
}
-void ParamTraits<float>::Write(Message* m, const param_type& p) {
- m->WriteData(reinterpret_cast<const char*>(&p), sizeof(param_type));
-}
-
-bool ParamTraits<float>::Read(const Message* m, PickleIterator* iter,
- param_type* r) {
- const char *data;
- int data_size;
- if (!m->ReadData(iter, &data, &data_size) ||
- data_size != sizeof(param_type)) {
- NOTREACHED();
- return false;
- }
- memcpy(r, data, sizeof(param_type));
- return true;
-}
-
void ParamTraits<float>::Log(const param_type& p, std::string* l) {
l->append(base::StringPrintf("%e", p));
}
void ParamTraits<double>::Write(Message* m, const param_type& p) {
- m->WriteData(reinterpret_cast<const char*>(&p), sizeof(param_type));
+ m->WriteBytes(reinterpret_cast<const char*>(&p), sizeof(param_type));
}
bool ParamTraits<double>::Read(const Message* m, PickleIterator* iter,
param_type* r) {
const char *data;
- int data_size;
- if (!m->ReadData(iter, &data, &data_size) ||
- data_size != sizeof(param_type)) {
+ if (!m->ReadBytes(iter, &data, sizeof(*r))) {
NOTREACHED();
return false;
}
« no previous file with comments | « ipc/ipc_message_utils.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698