Skip to content

Commit

Permalink
Support really big yaml files
Browse files Browse the repository at this point in the history
  • Loading branch information
EdwardCooke committed Jul 5, 2024
1 parent 08fbe44 commit 8c1dbad
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 19 deletions.
1 change: 1 addition & 0 deletions YamlDotNet.Core7AoTCompileTest/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
using System.Globalization;
using System.IO;
using System.Security.Cryptography.X509Certificates;
using System.Threading.Tasks;
using YamlDotNet.Core;
using YamlDotNet.Core7AoTCompileTest.Model;
using YamlDotNet.Serialization;
Expand Down
6 changes: 3 additions & 3 deletions YamlDotNet/Core/Cursor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ namespace YamlDotNet.Core
[DebuggerStepThrough]
public sealed class Cursor
{
public int Index { get; private set; }
public int Line { get; private set; }
public int LineOffset { get; private set; }
public long Index { get; private set; }
public long Line { get; private set; }
public long LineOffset { get; private set; }

public Cursor()
{
Expand Down
8 changes: 4 additions & 4 deletions YamlDotNet/Core/Mark.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,19 +37,19 @@ namespace YamlDotNet.Core
/// <summary>
/// Gets / sets the absolute offset in the file
/// </summary>
public int Index { get; }
public long Index { get; }

/// <summary>
/// Gets / sets the number of the line
/// </summary>
public int Line { get; }
public long Line { get; }

/// <summary>
/// Gets / sets the index of the column
/// </summary>
public int Column { get; }
public long Column { get; }

public Mark(int index, int line, int column)
public Mark(long index, long line, long column)
{
if (index < 0)
{
Expand Down
18 changes: 9 additions & 9 deletions YamlDotNet/Core/Scanner.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public class Scanner : IScanner
{ 'P', '\x2029' }
};

private readonly Stack<int> indents = new Stack<int>();
private readonly Stack<long> indents = new Stack<long>();
private readonly InsertionQueue<Token> tokens = new InsertionQueue<Token>();
private readonly Stack<SimpleKey> simpleKeys = new Stack<SimpleKey>();
private readonly CharacterAnalyzer<LookAheadBuffer> analyzer;
Expand All @@ -67,10 +67,10 @@ public class Scanner : IScanner
private bool streamStartProduced;
private bool streamEndProduced;
private bool plainScalarFollowedByComment;
private int flowSequenceStartLine;
private long flowSequenceStartLine;
private bool flowCollectionFetched = false;
private bool startFlowCollectionFetched = false;
private int indent = -1;
private long indent = -1;
private bool flowScalarFetched;
private bool simpleKeyAllowed;
private int flowLevel;
Expand Down Expand Up @@ -696,7 +696,7 @@ private void FetchStreamStart()
/// the BLOCK-END token.
/// </summary>

private void UnrollIndent(int column)
private void UnrollIndent(long column)
{
// In the flow context, do nothing.

Expand Down Expand Up @@ -1220,7 +1220,7 @@ private void FetchValue()
/// the current column is greater than the indentation level. In this case,
/// append or insert the specified token into the token queue.
/// </summary>
private void RollIndent(int column, int number, bool isSequence, Mark position)
private void RollIndent(long column, int number, bool isSequence, Mark position)
{
// In the flow context, do nothing.

Expand Down Expand Up @@ -1492,7 +1492,7 @@ Token ScanBlockScalar(bool isLiteral)

var chomping = 0;
var increment = 0;
var currentIndent = 0;
var currentIndent = (long)0;
var leadingBlank = false;
bool? isFirstLine = null;

Expand Down Expand Up @@ -1683,10 +1683,10 @@ Token ScanBlockScalar(bool isLiteral)
/// indentation level if needed.
/// </summary>

private int ScanBlockScalarBreaks(int currentIndent, StringBuilder breaks, bool isLiteral, ref Mark end, ref bool? isFirstLine)
private long ScanBlockScalarBreaks(long currentIndent, StringBuilder breaks, bool isLiteral, ref Mark end, ref bool? isFirstLine)
{
var maxIndent = 0;
var indentOfFirstLine = -1;
var maxIndent = (long)0;
var indentOfFirstLine = (long)-1;

end = cursor.Mark();

Expand Down
6 changes: 3 additions & 3 deletions YamlDotNet/Core/SimpleKey.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ public void MarkAsImpossible()

public bool IsRequired { get; }
public int TokenNumber { get; }
public int Index => cursor.Index;
public int Line => cursor.Line;
public int LineOffset => cursor.LineOffset;
public long Index => cursor.Index;
public long Line => cursor.Line;
public long LineOffset => cursor.LineOffset;

public Mark Mark => cursor.Mark();

Expand Down

0 comments on commit 8c1dbad

Please sign in to comment.