Add StringUtil.Format overload to avoid unnecessary allocations (#13408)

* Rename parameters to correspond to string.Format

* Add addtional overload to avoid allocations at call sites
This commit is contained in:
xtqqczze
2020-08-24 09:10:54 +05:00
committed by GitHub
parent 6615fa3df6
commit 3594ac60c7
@@ -11,26 +11,17 @@ namespace System.Management.Automation.Internal
internal static
class StringUtil
{
internal static
string
Format(string formatSpec, object o)
{
return string.Format(System.Globalization.CultureInfo.CurrentCulture, formatSpec, o);
}
internal static string Format(string format, object arg0)
=> string.Format(Globalization.CultureInfo.CurrentCulture, format, arg0);
internal static
string
Format(string formatSpec, object o1, object o2)
{
return string.Format(System.Globalization.CultureInfo.CurrentCulture, formatSpec, o1, o2);
}
internal static string Format(string format, object arg0, object arg1)
=> string.Format(Globalization.CultureInfo.CurrentCulture, format, arg0, arg1);
internal static
string
Format(string formatSpec, params object[] o)
{
return string.Format(System.Globalization.CultureInfo.CurrentCulture, formatSpec, o);
}
internal static string Format(string format, object arg0, object arg1, object arg2)
=> string.Format(Globalization.CultureInfo.CurrentCulture, format, arg0, arg1, arg2);
internal static string Format(string format, params object[] args)
=> string.Format(Globalization.CultureInfo.CurrentCulture, format, args);
internal static
string