diff options
| author | jacqueline <me@jacqueline.id.au> | 2023-07-12 10:36:06 +1000 |
|---|---|---|
| committer | jacqueline <me@jacqueline.id.au> | 2023-07-12 10:36:06 +1000 |
| commit | df22bed0724b3a0d04c9fefd0f5bb130945a6b4e (patch) | |
| tree | 919ad6d6dcb611aa5cb1710efd9425655caf8960 /src/database/index.cpp | |
| parent | 67ab8bf5153f9391b8b728bc932ea8414e18c511 (diff) | |
| download | tangara-fw-df22bed0724b3a0d04c9fefd0f5bb130945a6b4e.tar.gz | |
Include title in indexes to avoid a per-record disk read
GOTTA GO FAST
Diffstat (limited to 'src/database/index.cpp')
| -rw-r--r-- | src/database/index.cpp | 9 |
1 files changed, 7 insertions, 2 deletions
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<std::string> 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. |
