db::Writer::load use size_hint for table.reserve

This commit is contained in:
Dmitry Belyaev 2022-10-13 21:23:55 +03:00
parent 38cee92d5f
commit 78b319e41a

View File

@ -112,6 +112,12 @@ where
where
I: Iterator<Item = T>,
{
let hint = iter.size_hint();
let hint = std::cmp::max(hint.0, hint.1.unwrap_or(0));
if hint > 0 {
self.table.reserve(hint);
}
for item in iter {
self.push(item)?;
}