Skip to content

Commit

Permalink
change sep from string to char (#69)
Browse files Browse the repository at this point in the history
  • Loading branch information
leandromoh authored Sep 26, 2023
1 parent e6a1efc commit f84ea21
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
2 changes: 1 addition & 1 deletion RecordParser.Benchmark/VariableLengthReaderBenchmark.cs
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ public void Read_VariableLength_RecordParser_Raw(bool parallel, bool quoted)
ContainsQuotedFields = quoted,

ColumnCount = 8,
Separator = ",",
Separator = ',',
StringPoolFactory = () => new InternPool().Intern
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public class VariableLengthReaderRawOptions

public int ColumnCount { get; set; }
// TODO change to char
public string Separator { get; set; }
public char Separator { get; set; }
public ParallelOptions ParallelOptions { get; set; }
public Func<StringPool> StringPoolFactory { get; set; }
}
Expand Down Expand Up @@ -65,9 +65,10 @@ private static Get BuildRaw(int collumnCount, bool hasTransform, bool trim)
public static IEnumerable<T> GetRecordsRaw<T>(this TextReader stream, VariableLengthReaderRawOptions options, Func<Func<int, string>, T> reader)
{
var get = BuildRaw(options.ColumnCount, options.StringPoolFactory != null, options.Trim);
var sep = options.Separator.ToString();

Func<IFL> func = options.ContainsQuotedFields
? () => new RowByQuote(stream, Length, options.Separator)
? () => new RowByQuote(stream, Length, sep)
: () => new RowByLine(stream, Length);

var parallelOptions = options.ParallelOptions ?? new();
Expand All @@ -86,7 +87,7 @@ IEnumerable<T> GetSequential()

T Parser(ReadOnlyMemory<char> memory, int i)
{
var finder = new TextFindHelper(memory.Span, options.Separator, QuoteHelper.Quote);
var finder = new TextFindHelper(memory.Span, sep, QuoteHelper.Quote);

try
{
Expand Down Expand Up @@ -125,7 +126,7 @@ IEnumerable<T> GetParallel()

T Parser(ReadOnlyMemory<char> memory, int i)
{
var finder = new TextFindHelper(memory.Span, options.Separator, QuoteHelper.Quote);
var finder = new TextFindHelper(memory.Span, sep, QuoteHelper.Quote);

try
{
Expand Down

0 comments on commit f84ea21

Please sign in to comment.