Avoid deserializing object on deletion if there are no indexes

This commit is contained in:
Martchus 2022-05-31 21:17:37 +02:00
parent 9a9bed0f46
commit 9f17cdd3eb
1 changed files with 9 additions and 5 deletions

View File

@ -885,12 +885,16 @@ public:
//! Deletes an item from the main database and from indexes.
template <typename ElementType = T> void del(IDType id)
{
auto t = ElementType();
if (!this->get(id, t)) {
return;
if constexpr (std::tuple_size_v<tuple_t>) {
auto t = ElementType();
if (!this->get(id, t)) {
return;
}
(*d_txn)->del(d_parent->d_main, id);
clearIndex(id, t);
} else {
(*d_txn)->del(d_parent->d_main, id);
}
(*d_txn)->del(d_parent->d_main, id);
clearIndex(id, t);
}
//! Clears the database and indexes.