Skip to content

Commit 20a88f3

Browse files
author
SpaceCheetah
committed
Use TryGetValue
1 parent 8827c39 commit 20a88f3

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

LiteDB/Client/Storage/LiteFileStream.Read.cs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,11 +62,14 @@ private void SetReadStreamPosition(long newPosition)
6262
int loadedChunk = _currentChunkIndex;
6363
int newChunkIndex = 0;
6464
while (seekStreamPosition <= _streamPosition) {
65-
if (!_chunkLengths.ContainsKey(newChunkIndex)) {
65+
if (_chunkLengths.TryGetValue(newChunkIndex, out long length)) {
66+
seekStreamPosition += length;
67+
}
68+
else {
6669
loadedChunk = newChunkIndex;
6770
_currentChunkData = GetChunkData(newChunkIndex);
71+
seekStreamPosition += _currentChunkData.Length;
6872
}
69-
seekStreamPosition += _chunkLengths[newChunkIndex];
7073
newChunkIndex++;
7174
}
7275
newChunkIndex--;

0 commit comments

Comments
 (0)