Skip to content

Commit 1972de9

Browse files
author
Mallory Paine
committed
When growing image table file, grow in increments of _entriesPerChunk.
1 parent 2c44f77 commit 1972de9

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

FastImageCache/FICImageTable.m

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,11 @@ - (void)setEntryForEntityUUID:(NSString *)entityUUID sourceImageUUID:(NSString *
257257
newEntryIndex = [self _nextEntryIndex];
258258

259259
if (newEntryIndex >= _entryCount) {
260-
NSInteger newEntryCount = _entryCount + MAX(_entriesPerChunk, newEntryIndex - _entryCount + 1);
260+
// Determine how many chunks we need to support new entry index.
261+
// Number of entries should always be a multiple of _entriesPerChunk
262+
NSInteger numberOfEntriesRequired = newEntryIndex + 1;
263+
NSInteger newChunkCount = _entriesPerChunk > 0 ? ((numberOfEntriesRequired + _entriesPerChunk - 1) / _entriesPerChunk) : 0;
264+
NSInteger newEntryCount = newChunkCount * _entriesPerChunk;
261265
[self _setEntryCount:newEntryCount];
262266
}
263267
}

0 commit comments

Comments
 (0)