[objcruntime] Avoid intermediate strings for formatting (#12297)

... when a `StringBuilder` is used inside

* Runtime.PrintException
* Runtime.PrintAllExceptions
This commit is contained in:
Sebastien Pouliot 2021-08-03 09:04:54 -04:00 коммит произвёл GitHub
Родитель 18a9a90450
Коммит 1fc007cdee
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
1 изменённых файлов: 2 добавлений и 2 удалений

Просмотреть файл

@ -508,7 +508,7 @@ namespace ObjCRuntime {
{
if (isInnerException)
sb.AppendLine (" --- inner exception ---");
sb.AppendLine ($"{exc.Message} ({exc.GetType ().FullName})");
sb.Append (exc.Message).Append (" (").Append (exc.GetType ().FullName).AppendLine (")");
var trace = exc.StackTrace;
if (!string.IsNullOrEmpty (trace))
sb.AppendLine (trace);
@ -526,7 +526,7 @@ namespace ObjCRuntime {
exc = exc.InnerException;
} while (counter < 10 && exc != null);
} catch (Exception exception) {
str.Append ($"Failed to print exception: {exception}");
str.Append ("Failed to print exception: ").Append (exception);
}
return Marshal.StringToHGlobalAuto (str.ToString ());