Skip to content

Commit

Permalink
made some methods readonly
Browse files Browse the repository at this point in the history
  • Loading branch information
j0nimost committed Oct 25, 2023
1 parent e8efe85 commit 47d985a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
9 changes: 4 additions & 5 deletions src/Kafa/Reader/KafaReader.Col.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System.Reflection.PortableExecutable;
using System.Runtime.CompilerServices;
using System.Runtime.CompilerServices;

namespace nyingi.Kafa.Reader
{
Expand Down Expand Up @@ -37,7 +36,7 @@ public Col(ColEnumerable colEnumerable, string columnName)


[MethodImpl(MethodImplOptions.AggressiveInlining)]
public bool TryParse<T>(out T result) where T : ISpanParsable<T> => _colEnumerable.TryParse(Value, out result);
public bool TryParse<T>(out T? result) where T : ISpanParsable<T> => _colEnumerable.TryParse(Value, out result);

public override string ToString()
{
Expand Down Expand Up @@ -95,12 +94,12 @@ public ReadOnlySpan<char> ReadColSpan(int index)
}


public T Parse<T>(ReadOnlySpan<char> scanSpan) where T : ISpanParsable<T>
public readonly T Parse<T>(ReadOnlySpan<char> scanSpan) where T : ISpanParsable<T>
{
return T.Parse(scanSpan, _reader.cultureInfo);
}

public bool TryParse<T>(ReadOnlySpan<char> colValue, out T result) where T : ISpanParsable<T>
public readonly bool TryParse<T>(ReadOnlySpan<char> colValue, out T? result) where T : ISpanParsable<T>
{
return T.TryParse(colValue, _reader.cultureInfo, out result);
}
Expand Down
4 changes: 2 additions & 2 deletions src/Kafa/Reader/KafaReader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public KafaReader(in KafaReadState kafaReadState)
public OrderedDictionary? Headers => _kafaReadState.Headers;

[MethodImpl(MethodImplOptions.AggressiveInlining)]
public ReadOnlyMemory<char> ReadRowSpan(int index, out int lastColMarkerIndex)
public readonly ReadOnlyMemory<char> ReadRowSpan(int index, out int lastColMarkerIndex)
{
lastColMarkerIndex = index + ColumnCount;

Expand All @@ -51,7 +51,7 @@ public ReadOnlyMemory<char> ReadRowSpan(int index, out int lastColMarkerIndex)
}

[MethodImpl(MethodImplOptions.AggressiveInlining)]
public ReadOnlySpan<char> ReadColSpan(int startIndex, int lastIndex)
public readonly ReadOnlySpan<char> ReadColSpan(int startIndex, int lastIndex)
{
return _kafaReadState.Buffer.AsSpan(startIndex, lastIndex - startIndex);
}
Expand Down

0 comments on commit 47d985a

Please sign in to comment.