Skip to content

Commit

Permalink
Herix: Add function to invalidate chunks, and call it where it should be
Browse files Browse the repository at this point in the history
  • Loading branch information
MinusGix committed Sep 12, 2019
1 parent d3ef345 commit 855bd35
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/herix.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,11 @@ bool Herix::hasChunk (size_t id) const {
return id < chunks.size();
}

// Throws away all the chunks.
void Herix::invalidateChunks () {
chunks.clear();
}

/// Cleanup the chunks if they've gone over the limit.
/// Tries disposing of them in least used order and least recently loaded
void Herix::cleanupChunks () {
Expand Down Expand Up @@ -319,6 +324,7 @@ void Herix::saveHistoryDestructive () {
file.write(reinterpret_cast<const char *>(edit.data.data()), static_cast<std::streamsize>(edit.data.size()));
}

invalidateChunks();
edits.clearNotStats();
}
/// Saves the files, to the filename. Overwrites if it already exists
Expand Down
1 change: 1 addition & 0 deletions src/herix.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ class Herix {
bool hasChunk (ChunkID id) const;

void cleanupChunks ();
void invalidateChunks ();


std::optional<Byte> read (FilePosition pos);
Expand Down

0 comments on commit 855bd35

Please sign in to comment.