clover: Optimize module serialization for vectors of fundamental types.

Tested-by: Tom Stellard <thomas.stellard@amd.com>
This commit is contained in:
Francisco Jerez
2014-06-14 20:53:35 +02:00
parent cad60420d5
commit ab023c27a3
@@ -69,7 +69,9 @@ namespace {
/// (De)serialize a vector.
template<typename T>
struct _serializer<compat::vector<T>> {
struct _serializer<compat::vector<T>,
typename std::enable_if<
!std::is_scalar<T>::value>::type> {
static void
proc(compat::ostream &os, const compat::vector<T> &v) {
_proc<uint32_t>(os, v.size());
@@ -87,6 +89,25 @@ namespace {
}
};
template<typename T>
struct _serializer<compat::vector<T>,
typename std::enable_if<
std::is_scalar<T>::value>::type> {
static void
proc(compat::ostream &os, const compat::vector<T> &v) {
_proc<uint32_t>(os, v.size());
os.write(reinterpret_cast<const char *>(v.begin()),
v.size() * sizeof(T));
}
static void
proc(compat::istream &is, compat::vector<T> &v) {
v.reserve(_proc<uint32_t>(is));
is.read(reinterpret_cast<char *>(v.begin()),
v.size() * sizeof(T));
}
};
/// (De)serialize a module::section.
template<>
struct _serializer<module::section> {