A fork of https://github.com/crosspoint-reader/crosspoint-reader
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

refactor: Avoid rebuilding cache path strings (#1300)

## Summary

**What is the goal of this PR?**

Avoid building cache path strings twice, once to check existence of the
file and a second time to delete the file.

---

### AI Usage

While CrossPoint doesn't have restrictions on AI tools in contributing,
please be transparent about their usage as it
helps set the right context for reviewers.

Did you use AI tools to help write this code? _**NO**_

authored by

Zach Nelson and committed by
GitHub
a826569a 88594077

+9 -9
+6 -4
lib/Epub/Epub/BookMetadataCache.cpp
··· 274 274 } 275 275 276 276 bool BookMetadataCache::cleanupTmpFiles() const { 277 - if (Storage.exists((cachePath + tmpSpineBinFile).c_str())) { 278 - Storage.remove((cachePath + tmpSpineBinFile).c_str()); 277 + const auto spineBinFile = cachePath + tmpSpineBinFile; 278 + if (Storage.exists(spineBinFile.c_str())) { 279 + Storage.remove(spineBinFile.c_str()); 279 280 } 280 - if (Storage.exists((cachePath + tmpTocBinFile).c_str())) { 281 - Storage.remove((cachePath + tmpTocBinFile).c_str()); 281 + const auto tocBinFile = cachePath + tmpTocBinFile; 282 + if (Storage.exists(tocBinFile.c_str())) { 283 + Storage.remove(tocBinFile.c_str()); 282 284 } 283 285 return true; 284 286 }
+3 -5
lib/Epub/Epub/parsers/ContentOpfParser.cpp
··· 36 36 if (tempItemStore) { 37 37 tempItemStore.close(); 38 38 } 39 - if (Storage.exists((cachePath + itemCacheFile).c_str())) { 40 - Storage.remove((cachePath + itemCacheFile).c_str()); 39 + const auto itemCachePath = cachePath + itemCacheFile; 40 + if (Storage.exists(itemCachePath.c_str())) { 41 + Storage.remove(itemCachePath.c_str()); 41 42 } 42 - itemIndex.clear(); 43 - itemIndex.shrink_to_fit(); 44 - useItemIndex = false; 45 43 } 46 44 47 45 size_t ContentOpfParser::write(const uint8_t data) { return write(&data, 1); }