Skip to content

Commit ebc7e4d

Browse files
committed
dont pre-allocate port buffer
1 parent e71d10a commit ebc7e4d

File tree

1 file changed

+7
-10
lines changed

1 file changed

+7
-10
lines changed

src/Http/Owin/src/OwinEnvironment.cs

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -472,17 +472,14 @@ public OwinEntries(HttpContext context)
472472
};
473473
}
474474

475-
static readonly string[] PortStrings = CreatePortStrings();
476-
static string[] CreatePortStrings()
475+
static string PortToString(int port) => port switch
477476
{
478-
var ports = new string[65535]; // limit of ephemeral ports https://en.wikipedia.org/wiki/Ephemeral_port
479-
for (var i = 0; i < ports.Length; i++)
480-
{
481-
ports[i] = (i + 1).ToString(CultureInfo.InvariantCulture);
482-
}
483-
return ports;
484-
}
485-
static string PortToString(int port) => PortStrings[port - 1];
477+
80 => "80",
478+
443 => "443",
479+
8080 => "8080",
480+
8081 => "8081",
481+
_ => port.ToString(CultureInfo.InvariantCulture),
482+
};
486483

487484
public int Count
488485
{

0 commit comments

Comments
 (0)