Skip to content

Commit d573f0d

Browse files
committed
optimize: add const string
1 parent 6480ed4 commit d573f0d

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

src/Plugins/SignClient/Settings.cs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -78,14 +78,16 @@ public static Settings Default
7878
{
7979
if (EndpointType != EndpointVsock) return null;
8080

81+
const string httpScheme = "http://";
82+
const string httpsScheme = "https://";
8183
var endpoint = Endpoint;
82-
if (Endpoint.StartsWith("http://"))
84+
if (endpoint.StartsWith(httpScheme))
8385
{
84-
endpoint = endpoint.Substring("http://".Length);
86+
endpoint = endpoint.Substring(httpScheme.Length);
8587
}
86-
else if (Endpoint.StartsWith("https://"))
88+
else if (endpoint.StartsWith(httpsScheme))
8789
{
88-
endpoint = endpoint.Substring("https://".Length);
90+
endpoint = endpoint.Substring(httpsScheme.Length);
8991
}
9092

9193
var parts = endpoint.Split(':', 2);

src/Plugins/SignClient/Vsock.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,15 +40,15 @@ public Vsock(VsockAddress address)
4040
_endpoint = new VSockEndPoint(address.ContextId, address.Port);
4141
}
4242

43-
internal async ValueTask<Stream> ConnectAsync(SocketsHttpConnectionContext context, CancellationToken cancellationToken)
43+
internal async ValueTask<Stream> ConnectAsync(SocketsHttpConnectionContext context, CancellationToken cancellation)
4444
{
4545
if (!OperatingSystem.IsLinux()) throw new PlatformNotSupportedException("Vsock is only supported on Linux.");
4646

4747
var socket = VSock.Create(SocketType.Stream);
4848
try
4949
{
5050
// Have to use `Task.Run` with `Connect` to avoid some compatibility issues(if use ConnectAsync).
51-
await Task.Run(() => socket.Connect(_endpoint), cancellationToken);
51+
await Task.Run(() => socket.Connect(_endpoint), cancellation);
5252
return new NetworkStream(socket, true);
5353
}
5454
catch

0 commit comments

Comments
 (0)