Skip to content

Commit

Permalink
Use string interpolation in a few more places (#82096)
Browse files Browse the repository at this point in the history
Places where we'd otherwise be allocating for at least one of the subcomponents.
  • Loading branch information
stephentoub authored Feb 14, 2023
1 parent c6ae51c commit cbc8695
Show file tree
Hide file tree
Showing 6 changed files with 7 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -472,7 +472,7 @@ public override string ToString()
}
else
{
classAndValue = TagClass + "-" + TagValue;
classAndValue = $"{TagClass}-{TagValue}";
}

if (IsConstructed)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ public ServicePoint ServicePoint
// be usable, whereas in .NET Framework it throws an exception that "This property is not supported for
// protocols that do not use URI."
#pragma warning disable SYSLIB0014
return _servicePoint ??= ServicePointManager.FindServicePoint(new Uri("mailto:" + _host + ":" + _port));
return _servicePoint ??= ServicePointManager.FindServicePoint(new Uri($"mailto:{_host}:{_port}"));
#pragma warning restore SYSLIB0014
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,7 @@ public string Host
Uri hostUri = _hostUri ?? Address;
return (_hostUri == null || !_hostHasPort) && Address.IsDefaultPort ?
hostUri.Host :
hostUri.Host + ":" + hostUri.Port;
$"{hostUri.Host}:{hostUri.Port}";
}
set
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -197,8 +197,8 @@ private static bool ProxyAddressIfNecessary(ref Uri address, IWebProxy? proxy)
}

private static string MakeQueryString(Uri address) => address.IsDefaultPort ?
address.Scheme + "://" + address.DnsSafeHost :
address.Scheme + "://" + address.DnsSafeHost + ":" + address.Port.ToString();
$"{address.Scheme}://{address.DnsSafeHost}" :
$"{address.Scheme}://{address.DnsSafeHost}:{address.Port}";

private static string MakeQueryString(Uri address, bool isProxy)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ private static string NormalizeActivityName(string providerName, string activity
}
else if (task != 0)
{
return providerName + "task" + task.ToString();
return $"{providerName}task{task}";
}
else
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ private ProxyBuilder CreateProxy(
[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicParameterlessConstructor)] Type proxyBaseType)
{
int nextId = Interlocked.Increment(ref _typeId);
TypeBuilder tb = _mb.DefineType(name + "_" + nextId, TypeAttributes.Public, proxyBaseType);
TypeBuilder tb = _mb.DefineType($"{name}_{nextId}", TypeAttributes.Public, proxyBaseType);
return new ProxyBuilder(this, tb, proxyBaseType);
}

Expand Down

0 comments on commit cbc8695

Please sign in to comment.