Skip to content

Commit a5e2774

Browse files
authored
Merge pull request #77 from SimonCropp/avoid-alloc-of-sizePart-if-numberpart-is-a-match
avoid alloc of sizePart if numberpart is a match
2 parents 28f1bd5 + 3156252 commit a5e2774

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/ByteSizeLib/ByteSize.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -583,13 +583,13 @@ public static ByteSize Parse(string s, NumberStyles numberStyles, IFormatProvide
583583

584584
// Cut the input string in half
585585
string numberPart = s.Substring(0, lastNumber).Trim();
586-
string sizePart = s.Substring(lastNumber, s.Length - lastNumber).Trim();
587586

588587
// Get the numeric part
589588
double number;
590589
if (!double.TryParse(numberPart, numberStyles, formatProvider, out number))
591590
throw new FormatException($"No number found in value '{s}'.");
592591

592+
string sizePart = s.Substring(lastNumber, s.Length - lastNumber).Trim();
593593
// Get the magnitude part
594594
switch (sizePart)
595595
{

0 commit comments

Comments
 (0)