perf(library/module): use block read

This commit is contained in:
Leonardo de Moura 2015-08-14 17:56:21 -07:00
parent 54a49bbf2e
commit 849b99d244
3 changed files with 8 additions and 2 deletions

View file

@ -367,8 +367,7 @@ struct import_modules_fn {
unsigned code_size = d1.read_unsigned();
std::vector<char> code(code_size);
for (unsigned i = 0; i < code_size; i++)
code[i] = d1.read_char();
d1.read(code);
unsigned computed_hash = hash(code_size, [&](unsigned i) { return code[i]; });
if (claimed_hash != computed_hash)

View file

@ -108,4 +108,9 @@ double deserializer_core::read_double() {
in >> r;
return r;
}
void deserializer_core::read(std::vector<char> & data) {
unsigned sz = data.size();
m_in.read(data.data(), sz);
}
}

View file

@ -60,6 +60,8 @@ public:
char read_char() { return m_in.get(); }
bool read_bool() { return m_in.get() != 0; }
double read_double();
// read data.size() bytes from input stream and store it at data
void read(std::vector<char> & data);
};
typedef extensible_object<deserializer_core> deserializer;