Skip to content

Commit 1ece12c

Browse files
committed
Removed a string allocation from numeric token parsing.
1 parent 1fa4e6c commit 1ece12c

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

SqlServerSimulator/Parser/Tokens/Numeric.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,13 @@ namespace SqlServerSimulator.Parser.Tokens;
44

55
internal sealed class Numeric : Token
66
{
7-
public readonly IFormattable Value;
7+
public readonly ISpanFormattable Value;
88

99
public Numeric(StringBuilder buffer)
1010
{
11-
var number = buffer.ToString();
11+
Span<char> number = stackalloc char[buffer.Length];
12+
buffer.CopyTo(0, number, buffer.Length);
13+
_ = buffer.Clear();
1214

1315
if (int.TryParse(number, out var int32))
1416
{

0 commit comments

Comments
 (0)