fix(nvs): Fixed Page::findItem performance degradation

Wrong condition gating the hash map use causing performance degradation was corrected

The condition enabling use of hash map when page is searched for Item was modified
to correct the bug introduced by commit addressing delete of any BLOB_INDEX Items.
This correction returns the performance of findItem to the state before previous change.
This commit is contained in:
radek.tandler 2024-03-07 11:30:35 +01:00
parent c8651c1041
commit 508d9a6a22

View File

@ -882,7 +882,7 @@ esp_err_t Page::findItem(uint8_t nsIndex, ItemType datatype, const char* key, si
// For BLOB_DATA, we may need to search for all chunk indexes, so the hash list won't help // For BLOB_DATA, we may need to search for all chunk indexes, so the hash list won't help
// mHashIndex caluclates hash from nsIndex, key, chunkIdx // mHashIndex caluclates hash from nsIndex, key, chunkIdx
// We may not use mHashList if datatype is BLOB_DATA and chunkIdx is CHUNK_ANY as CHUNK_ANY is used by BLOB_INDEX // We may not use mHashList if datatype is BLOB_DATA and chunkIdx is CHUNK_ANY as CHUNK_ANY is used by BLOB_INDEX
if (nsIndex != NS_ANY && key != NULL && (datatype == ItemType::BLOB_DATA && chunkIdx != CHUNK_ANY)) { if (nsIndex != NS_ANY && key != NULL && (datatype != ItemType::BLOB_DATA || chunkIdx != CHUNK_ANY)) {
size_t cachedIndex = mHashList.find(start, Item(nsIndex, datatype, 0, key, chunkIdx)); size_t cachedIndex = mHashList.find(start, Item(nsIndex, datatype, 0, key, chunkIdx));
if (cachedIndex < ENTRY_COUNT) { if (cachedIndex < ENTRY_COUNT) {
start = cachedIndex; start = cachedIndex;