From: Francisco Jerez Date: Sat, 14 Jun 2014 18:53:35 +0000 (+0200) Subject: clover: Optimize module serialization for vectors of fundamental types. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=ab023c27a374bb69bd7300b5b6f0789844fc8ba9;p=mesa.git clover: Optimize module serialization for vectors of fundamental types. Tested-by: Tom Stellard --- diff --git a/src/gallium/state_trackers/clover/core/module.cpp b/src/gallium/state_trackers/clover/core/module.cpp index 3e3ad99e450..41de7344203 100644 --- a/src/gallium/state_trackers/clover/core/module.cpp +++ b/src/gallium/state_trackers/clover/core/module.cpp @@ -69,7 +69,9 @@ namespace { /// (De)serialize a vector. template - struct _serializer> { + struct _serializer, + typename std::enable_if< + !std::is_scalar::value>::type> { static void proc(compat::ostream &os, const compat::vector &v) { _proc(os, v.size()); @@ -87,6 +89,25 @@ namespace { } }; + template + struct _serializer, + typename std::enable_if< + std::is_scalar::value>::type> { + static void + proc(compat::ostream &os, const compat::vector &v) { + _proc(os, v.size()); + os.write(reinterpret_cast(v.begin()), + v.size() * sizeof(T)); + } + + static void + proc(compat::istream &is, compat::vector &v) { + v.reserve(_proc(is)); + is.read(reinterpret_cast(v.begin()), + v.size() * sizeof(T)); + } + }; + /// (De)serialize a module::section. template<> struct _serializer {