Skip to content

Commit

Permalink
dont pre-allocate port buffer
Browse files Browse the repository at this point in the history
  • Loading branch information
DeagleGross committed Nov 14, 2024
1 parent e71d10a commit ebc7e4d
Showing 1 changed file with 7 additions and 10 deletions.
17 changes: 7 additions & 10 deletions src/Http/Owin/src/OwinEnvironment.cs
Original file line number Diff line number Diff line change
Expand Up @@ -472,17 +472,14 @@ public OwinEntries(HttpContext context)
};
}

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

public int Count
{
Expand Down

0 comments on commit ebc7e4d

Please sign in to comment.