From df22bed0724b3a0d04c9fefd0f5bb130945a6b4e Mon Sep 17 00:00:00 2001 From: jacqueline Date: Wed, 12 Jul 2023 10:36:06 +1000 Subject: Include title in indexes to avoid a per-record disk read GOTTA GO FAST --- src/database/index.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'src/database/index.cpp') diff --git a/src/database/index.cpp b/src/database/index.cpp index a828578d..84d00bcd 100644 --- a/src/database/index.cpp +++ b/src/database/index.cpp @@ -52,15 +52,20 @@ auto Index(const IndexInfo& info, const Track& t, leveldb::WriteBatch* batch) key.item = {}; } - // If this is the last component, then we should also fill in the track id. + // If this is the last component, then we should also fill in the track id + // and title. + std::optional title; if (i == info.components.size() - 1) { key.track = t.data().id(); + if (info.components.at(i) != Tag::kTitle) { + title = t.TitleOrFilename(); + } } else { key.track = {}; } auto encoded = EncodeIndexKey(key); - batch->Put(encoded.slice, leveldb::Slice{}); + batch->Put(encoded.slice, title.value_or("")); // If there are more components after this, then we need to finish by // narrowing the header with the current title. -- cgit v1.2.3