Avoid string allocation when converting zero (#19732)
This commit is contained in:
parent
88b134f877
commit
56a64a6ff0
|
|
@ -562,6 +562,11 @@ namespace Microsoft.Net.Http.Headers
|
||||||
throw new ArgumentOutOfRangeException(nameof(value), value, "The value to be formatted must be non-negative.");
|
throw new ArgumentOutOfRangeException(nameof(value), value, "The value to be formatted must be non-negative.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (value == 0)
|
||||||
|
{
|
||||||
|
return "0";
|
||||||
|
}
|
||||||
|
|
||||||
var position = _int64MaxStringLength;
|
var position = _int64MaxStringLength;
|
||||||
char* charBuffer = stackalloc char[_int64MaxStringLength];
|
char* charBuffer = stackalloc char[_int64MaxStringLength];
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue