Skip to content

Commit

Permalink
Correcting some typos
Browse files Browse the repository at this point in the history
  • Loading branch information
kcsombrio committed Jan 11, 2021
1 parent 2e2f150 commit 72add7f
Show file tree
Hide file tree
Showing 7 changed files with 40 additions and 40 deletions.
6 changes: 3 additions & 3 deletions LiteDB/Engine/Disk/MemoryCache.cs
Original file line number Diff line number Diff line change
Expand Up @@ -298,13 +298,13 @@ private PageBuffer GetFreePage()
/// </summary>
private void Extend()
{
// count how many pages in cache are avaiable to be re-used (is not in use at this time)
// count how many pages in cache are available to be re-used (is not in use at this time)
var emptyShareCounter = _readable.Values.Count(x => x.ShareCounter == 0);

// get segmentSize
var segmentSize = _segmentSizes[Math.Min(_segmentSizes.Length - 1, _extends)];

// if this count are larger than MEMORY_SEGMENT_SIZE, re-use all this pages
// if this count is larger than MEMORY_SEGMENT_SIZE, re-use all this pages
if (emptyShareCounter > segmentSize)
{
// get all readable pages that can return to _free (slow way)
Expand Down Expand Up @@ -352,7 +352,7 @@ private void Extend()
// create big linear array in heap memory (LOH => 85Kb)
var buffer = new byte[PAGE_SIZE * segmentSize];

// slit linear array into many array slices
// split linear array into many array slices
for (var i = 0; i < segmentSize; i++)
{
var uniqueID = (_extends * segmentSize) + i + 1;
Expand Down
40 changes: 20 additions & 20 deletions LiteDB/Engine/Disk/Serializer/BufferReader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
namespace LiteDB.Engine
{
/// <summary>
/// Read multiple array segment as a single linear segment - Fordward Only
/// Read multiple array segment as a single linear segment - Forward Only
/// </summary>
internal class BufferReader : IDisposable
{
Expand Down Expand Up @@ -55,15 +55,15 @@ public BufferReader(IEnumerable<BufferSlice> source, bool utcDate = false)
#region Basic Read

/// <summary>
/// Move fordward in current segment. If array segment finish, open next segment
/// Returns true if move to another segment - returns false if continue in same segment
/// Move forward in current segment. If array segment finishes, open next segment
/// Returns true if moved to another segment - returns false if continues in the same segment
/// </summary>
private bool MoveFordward(int count)
private bool MoveForward(int count)
{
// do not move fordward if source finish
// do not move forward if source finish
if (_isEOF) return false;

ENSURE(_currentPosition + count <= _current.Count, "fordward are only for current segment");
ENSURE(_currentPosition + count <= _current.Count, "forward is only for current segment");

_currentPosition += count;
_position += count;
Expand Down Expand Up @@ -112,7 +112,7 @@ public int Read(byte[] buffer, int offset, int count)
bufferPosition += bytesToCopy;

// move position in current segment (and go to next segment if finish)
this.MoveFordward(bytesToCopy);
this.MoveForward(bytesToCopy);

if (_isEOF) break;
}
Expand Down Expand Up @@ -156,7 +156,7 @@ public string ReadString(int count)
{
value = Encoding.UTF8.GetString(_current.Array, _current.Offset + _currentPosition, count);

this.MoveFordward(count);
this.MoveForward(count);
}
else
{
Expand Down Expand Up @@ -192,17 +192,17 @@ public string ReadCString()

mem.Write(_current.Array, _current.Offset + _currentPosition, initialCount);

this.MoveFordward(initialCount);
this.MoveForward(initialCount);

// and go to next segment
while (_current[_currentPosition] != 0x00 && _isEOF == false)
{
mem.WriteByte(_current[_currentPosition]);

this.MoveFordward(1);
this.MoveForward(1);
}

this.MoveFordward(1); // +1 to '\0'
this.MoveForward(1); // +1 to '\0'

return Encoding.UTF8.GetString(mem.ToArray());
}
Expand All @@ -221,7 +221,7 @@ private bool TryReadCStringCurrentSegment(out string value)
if (_current[pos] == 0x00)
{
value = Encoding.UTF8.GetString(_current.Array, _current.Offset + _currentPosition, count);
this.MoveFordward(count + 1); // +1 means '\0'
this.MoveForward(count + 1); // +1 means '\0'
return true;
}
else
Expand All @@ -247,7 +247,7 @@ private T ReadNumber<T>(Func<byte[], int, T> convert, int size)
{
value = convert(_current.Array, _current.Offset + _currentPosition);

this.MoveFordward(size);
this.MoveForward(size);
}
else
{
Expand Down Expand Up @@ -302,7 +302,7 @@ public Guid ReadGuid()
{
value = _current.ReadGuid(_currentPosition);

this.MoveFordward(16);
this.MoveForward(16);
}
else
{
Expand All @@ -324,7 +324,7 @@ public ObjectId ReadObjectId()
{
value = new ObjectId(_current.Array, _current.Offset + _currentPosition);

this.MoveFordward(12);
this.MoveForward(12);
}
else
{
Expand All @@ -346,7 +346,7 @@ public ObjectId ReadObjectId()
public bool ReadBoolean()
{
var value = _current[_currentPosition] != 0;
this.MoveFordward(1);
this.MoveForward(1);
return value;
}

Expand All @@ -356,7 +356,7 @@ public bool ReadBoolean()
public byte ReadByte()
{
var value = _current[_currentPosition];
this.MoveFordward(1);
this.MoveForward(1);
return value;
}

Expand Down Expand Up @@ -444,7 +444,7 @@ public BsonDocument ReadDocument(HashSet<string> fields = null)
}
}

this.MoveFordward(1); // skip \0
this.MoveForward(1); // skip \0

return doc;
}
Expand All @@ -464,7 +464,7 @@ public BsonArray ReadArray()
arr.Add(value);
}

this.MoveFordward(1); // skip \0
this.MoveForward(1); // skip \0

return arr;
}
Expand Down Expand Up @@ -508,7 +508,7 @@ private BsonValue ReadElement(HashSet<string> remaining, out string name)
{
var length = this.ReadInt32();
var value = this.ReadString(length - 1);
this.MoveFordward(1); // read '\0'
this.MoveForward(1); // read '\0'
return value;
}
else if (type == 0x03) // Document
Expand Down
26 changes: 13 additions & 13 deletions LiteDB/Engine/Disk/Serializer/BufferWriter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
namespace LiteDB.Engine
{
/// <summary>
/// Write data types/BSON data into byte[]. It's fordward only and support multi buffer slice as source
/// Write data types/BSON data into byte[]. It's forward only and support multi buffer slice as source
/// </summary>
internal class BufferWriter : IDisposable
{
Expand Down Expand Up @@ -51,15 +51,15 @@ public BufferWriter(IEnumerable<BufferSlice> source)
#region Basic Write

/// <summary>
/// Move fordward in current segment. If array segment finish, open next segment
/// Move forward in current segment. If array segment finish, open next segment
/// Returns true if move to another segment - returns false if continue in same segment
/// </summary>
private bool MoveFordward(int count)
private bool MoveForward(int count)
{
// do not move fordward if source finish
// do not move forward if source finish
if (_isEOF) return false;

ENSURE(_currentPosition + count <= _current.Count, "fordward are only for current segment");
ENSURE(_currentPosition + count <= _current.Count, "forward is only for current segment");

_currentPosition += count;
_position += count;
Expand Down Expand Up @@ -108,7 +108,7 @@ public int Write(byte[] buffer, int offset, int count)
bufferPosition += bytesToCopy;

// move position in current segment (and go to next segment if finish)
this.MoveFordward(bytesToCopy);
this.MoveForward(bytesToCopy);

if (_isEOF) break;
}
Expand Down Expand Up @@ -162,7 +162,7 @@ public void WriteCString(string value)

_current[_currentPosition + bytesCount] = 0x00;

this.MoveFordward(bytesCount + 1); // +1 to '\0'
this.MoveForward(bytesCount + 1); // +1 to '\0'
}
else
{
Expand All @@ -174,7 +174,7 @@ public void WriteCString(string value)

_current[_currentPosition] = 0x00;

this.MoveFordward(1);
this.MoveForward(1);

BufferPool.Return(buffer);
}
Expand All @@ -197,7 +197,7 @@ public void WriteString(string value, bool specs)
{
Encoding.UTF8.GetBytes(value, 0, value.Length, _current.Array, _current.Offset + _currentPosition);

this.MoveFordward(count);
this.MoveForward(count);
}
else
{
Expand Down Expand Up @@ -227,7 +227,7 @@ private void WriteNumber<T>(T value, Action<T, byte[], int> toBytes, int size)
{
toBytes(value, _current.Array, _current.Offset + _currentPosition);

this.MoveFordward(size);
this.MoveForward(size);
}
else
{
Expand Down Expand Up @@ -289,7 +289,7 @@ public void Write(ObjectId value)
{
value.ToByteArray(_current.Array, _current.Offset + _currentPosition);

this.MoveFordward(12);
this.MoveForward(12);
}
else
{
Expand All @@ -309,7 +309,7 @@ public void Write(ObjectId value)
public void Write(bool value)
{
_current[_currentPosition] = value ? (byte)0x01 : (byte)0x00;
this.MoveFordward(1);
this.MoveForward(1);
}

/// <summary>
Expand All @@ -318,7 +318,7 @@ public void Write(bool value)
public void Write(byte value)
{
_current[_currentPosition] = value;
this.MoveFordward(1);
this.MoveForward(1);
}

/// <summary>
Expand Down
2 changes: 1 addition & 1 deletion LiteDB/Engine/Query/IndexQuery/IndexEquals.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public override IEnumerable<IndexNode> Execute(IndexService indexer, CollectionI
// navigate in both sides to return all nodes found
var first = node;

// first go fordward
// first go forward
while (!node.Next[0].IsEmpty && ((node = indexer.GetNode(node.Next[0])).Key.CompareTo(_value, indexer.Collation) == 0))
{
if (node.Key.IsMinValue || node.Key.IsMaxValue) break;
Expand Down
2 changes: 1 addition & 1 deletion LiteDB/Engine/Query/IndexQuery/IndexLike.cs
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ private IEnumerable<IndexNode> ExecuteStartsWith(IndexService indexer, Collectio
node = indexer.GetNode(node.GetNextPrev(0, -this.Order));
}

// move fordward
// move forward
node = indexer.GetNode(first.GetNextPrev(0, this.Order));

while (node != null)
Expand Down
2 changes: 1 addition & 1 deletion LiteDB/Engine/Services/IndexService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ public IndexNode GetNode(PageAddress address)
}

/// <summary>
/// Gets all node list from passed nodeAddress (fordward only)
/// Gets all node list from passed nodeAddress (forward only)
/// </summary>
public IEnumerable<IndexNode> GetNodeList(PageAddress nodeAddress)
{
Expand Down
2 changes: 1 addition & 1 deletion LiteDB/Utils/Constants.cs
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ internal class Constants

/// <summary>
/// Size, in PAGES, for each buffer array (used in MemoryStore)
/// It's an array to increase after each extend - limited in heighest value
/// It's an array to increase after each extend - limited in highest value
/// Each byte array will be created with this size * PAGE_SIZE
/// Use minimal 12 to allocate at least 85Kb per segment (will use LOH)
/// </summary>
Expand Down

0 comments on commit 72add7f

Please sign in to comment.