Skip to content

Commit

Permalink
Simplify loop
Browse files Browse the repository at this point in the history
- Remove local method.
- Use a single variable.
  • Loading branch information
martincostello committed Oct 17, 2024
1 parent eed92cb commit b509be1
Showing 1 changed file with 1 addition and 8 deletions.
9 changes: 1 addition & 8 deletions src/ProjectEuler/Puzzles/Puzzle059.cs
Original file line number Diff line number Diff line change
Expand Up @@ -82,17 +82,10 @@ private ReadOnlySpan<char> LoadText()

return string.Create(text.Length, text, (buffer, value) =>
{
int index = 0;

foreach (var range in value.Split(','))
{
buffer[index++] = ParseChar(value[range]);
buffer[length++] = (char)byte.Parse(value[range], CultureInfo.InvariantCulture);
}

length = index;

static char ParseChar(ReadOnlySpan<char> span)
=> (char)byte.Parse(span, CultureInfo.InvariantCulture);
}).AsSpan()[..length];
}
}

0 comments on commit b509be1

Please sign in to comment.