Current Situtation
The Scanner class which is used to return tokens from the input buffer currently only accepts a string.
public Scanner(string buffer)
{
Buffer = buffer ?? throw new ArgumentNullException(nameof(buffer));
Cursor = new Cursor(Buffer, TextPosition.Start);
}
This means, if we read this stream from a blob or a file, we initially have to allocate the entire string in memory.
Problem
A huge buffer string will end up on the LOH (large object heap) which can lead to several memory and performance problems.
https://learn.microsoft.com/en-us/dotnet/standard/garbage-collection/large-object-heap
Solution
Use a generic Stream instead of a plain string. As a result, it would be possible to directly stream the buffer from a blob or a file.
As a result, it would for example be possible to implement a streaming support for parsing (Fluid) templates.
Current Situtation
The
Scannerclass which is used to return tokens from the input buffer currently only accepts astring.This means, if we read this stream from a blob or a file, we initially have to allocate the entire
stringin memory.Problem
A huge
bufferstring will end up on the LOH (large object heap) which can lead to several memory and performance problems.https://learn.microsoft.com/en-us/dotnet/standard/garbage-collection/large-object-heap
Solution
Use a generic
Streaminstead of a plainstring. As a result, it would be possible to directly stream thebufferfrom a blob or a file.As a result, it would for example be possible to implement a streaming support for parsing (Fluid) templates.