Skip to content

Commit

Permalink
Use primary constructors
Browse files Browse the repository at this point in the history
  • Loading branch information
iamcarbon committed Dec 14, 2023
1 parent 804a6f0 commit b6a7acf
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 36 deletions.
30 changes: 8 additions & 22 deletions src/Markdig/Extensions/Tables/GridTableState.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,21 +10,15 @@ namespace Markdig.Extensions.Tables;
/// <summary>
/// Internal state used by the <see cref="GridTableParser"/>
/// </summary>
internal sealed class GridTableState
internal sealed class GridTableState(int start, bool expectRow)
{
public GridTableState(int start, bool expectRow)
{
Start = start;
ExpectRow = expectRow;
}

public int Start { get; }
public int Start { get; } = start;

public StringLineGroup Lines;

public List<ColumnSlice>? ColumnSlices { get; private set; }

public bool ExpectRow { get; }
public bool ExpectRow { get; } = expectRow;

public int StartRowGroup { get; set; }

Expand All @@ -45,26 +39,18 @@ public void AddColumn(int start, int end, TableColumnAlign? align)
ColumnSlices.Add(new ColumnSlice(start, end, align));
}

public sealed class ColumnSlice
public sealed class ColumnSlice(int start, int end, TableColumnAlign? align)
{
public ColumnSlice(int start, int end, TableColumnAlign? align)
{
Start = start;
End = end;
Align = align;
CurrentColumnSpan = -1;
}

/// <summary>
/// Gets or sets the index position of this column (after the |)
/// </summary>
public int Start { get; }
public int Start { get; } = start;

public int End { get; }
public int End { get; } = end;

public TableColumnAlign? Align { get; }
public TableColumnAlign? Align { get; } = align;

public int CurrentColumnSpan { get; set; }
public int CurrentColumnSpan { get; set; } = -1;

public int PreviousColumnSpan { get; set; }

Expand Down
18 changes: 4 additions & 14 deletions src/Markdig/Syntax/ContainerBlock.cs
Original file line number Diff line number Diff line change
Expand Up @@ -301,29 +301,19 @@ void IEnumerator.Reset()

#endregion

private sealed class BlockComparisonWrapper : IComparer<BlockWrapper>
private sealed class BlockComparisonWrapper(Comparison<Block> comparison) : IComparer<BlockWrapper>
{
private readonly Comparison<Block> _comparison;

public BlockComparisonWrapper(Comparison<Block> comparison)
{
_comparison = comparison;
}
private readonly Comparison<Block> _comparison = comparison;

public int Compare(BlockWrapper x, BlockWrapper y)
{
return _comparison(x.Block, y.Block);
}
}

private sealed class BlockComparerWrapper : IComparer<BlockWrapper>
private sealed class BlockComparerWrapper(IComparer<Block> comparer) : IComparer<BlockWrapper>
{
private readonly IComparer<Block> _comparer;

public BlockComparerWrapper(IComparer<Block> comparer)
{
_comparer = comparer;
}
private readonly IComparer<Block> _comparer = comparer;

public int Compare(BlockWrapper x, BlockWrapper y)
{
Expand Down

0 comments on commit b6a7acf

Please sign in to comment.