perf(library/module): use block read
This commit is contained in:
parent
54a49bbf2e
commit
849b99d244
3 changed files with 8 additions and 2 deletions
|
@ -367,8 +367,7 @@ struct import_modules_fn {
|
||||||
|
|
||||||
unsigned code_size = d1.read_unsigned();
|
unsigned code_size = d1.read_unsigned();
|
||||||
std::vector<char> code(code_size);
|
std::vector<char> code(code_size);
|
||||||
for (unsigned i = 0; i < code_size; i++)
|
d1.read(code);
|
||||||
code[i] = d1.read_char();
|
|
||||||
|
|
||||||
unsigned computed_hash = hash(code_size, [&](unsigned i) { return code[i]; });
|
unsigned computed_hash = hash(code_size, [&](unsigned i) { return code[i]; });
|
||||||
if (claimed_hash != computed_hash)
|
if (claimed_hash != computed_hash)
|
||||||
|
|
|
@ -108,4 +108,9 @@ double deserializer_core::read_double() {
|
||||||
in >> r;
|
in >> r;
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void deserializer_core::read(std::vector<char> & data) {
|
||||||
|
unsigned sz = data.size();
|
||||||
|
m_in.read(data.data(), sz);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -60,6 +60,8 @@ public:
|
||||||
char read_char() { return m_in.get(); }
|
char read_char() { return m_in.get(); }
|
||||||
bool read_bool() { return m_in.get() != 0; }
|
bool read_bool() { return m_in.get() != 0; }
|
||||||
double read_double();
|
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;
|
typedef extensible_object<deserializer_core> deserializer;
|
||||||
|
|
Loading…
Reference in a new issue