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

Side by Side Diff: ipc/ipc_message_utils.h

Issue 39363002: Optimize ParamTraits<float> and ParamTraits<double> (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 7 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | ipc/ipc_message_utils.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef IPC_IPC_MESSAGE_UTILS_H_ 5 #ifndef IPC_IPC_MESSAGE_UTILS_H_
6 #define IPC_IPC_MESSAGE_UTILS_H_ 6 #define IPC_IPC_MESSAGE_UTILS_H_
7 7
8 #include <algorithm> 8 #include <algorithm>
9 #include <map> 9 #include <map>
10 #include <set> 10 #include <set>
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after
209 } 209 }
210 IPC_EXPORT static void Log(const param_type& p, std::string* l); 210 IPC_EXPORT static void Log(const param_type& p, std::string* l);
211 }; 211 };
212 212
213 // Note that the IPC layer doesn't sanitize NaNs and +/- INF values. Clients 213 // Note that the IPC layer doesn't sanitize NaNs and +/- INF values. Clients
214 // should be sure to check the sanity of these values after receiving them over 214 // should be sure to check the sanity of these values after receiving them over
215 // IPC. 215 // IPC.
216 template <> 216 template <>
217 struct IPC_EXPORT ParamTraits<float> { 217 struct IPC_EXPORT ParamTraits<float> {
218 typedef float param_type; 218 typedef float param_type;
219 static void Write(Message* m, const param_type& p); 219 static void Write(Message* m, const param_type& p) {
220 static bool Read(const Message* m, PickleIterator* iter, param_type* r); 220 m->WriteFloat(p);
221 }
222 static bool Read(const Message* m, PickleIterator* iter, param_type* r) {
223 return m->ReadFloat(iter, r);
224 }
221 static void Log(const param_type& p, std::string* l); 225 static void Log(const param_type& p, std::string* l);
222 }; 226 };
223 227
224 template <> 228 template <>
225 struct IPC_EXPORT ParamTraits<double> { 229 struct IPC_EXPORT ParamTraits<double> {
226 typedef double param_type; 230 typedef double param_type;
227 static void Write(Message* m, const param_type& p); 231 static void Write(Message* m, const param_type& p);
228 static bool Read(const Message* m, PickleIterator* iter, param_type* r); 232 static bool Read(const Message* m, PickleIterator* iter, param_type* r);
229 static void Log(const param_type& p, std::string* l); 233 static void Log(const param_type& p, std::string* l);
230 }; 234 };
(...skipping 643 matching lines...) Expand 10 before | Expand all | Expand 10 after
874 template<typename TA, typename TB, typename TC, typename TD, typename TE> 878 template<typename TA, typename TB, typename TC, typename TD, typename TE>
875 static void WriteReplyParams(Message* reply, TA a, TB b, TC c, TD d, TE e) { 879 static void WriteReplyParams(Message* reply, TA a, TB b, TC c, TD d, TE e) {
876 ReplyParam p(a, b, c, d, e); 880 ReplyParam p(a, b, c, d, e);
877 WriteParam(reply, p); 881 WriteParam(reply, p);
878 } 882 }
879 }; 883 };
880 884
881 } // namespace IPC 885 } // namespace IPC
882 886
883 #endif // IPC_IPC_MESSAGE_UTILS_H_ 887 #endif // IPC_IPC_MESSAGE_UTILS_H_
OLDNEW
« no previous file with comments | « no previous file | ipc/ipc_message_utils.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698