Files
UnrealEngineUWP/Engine/Source/Programs/DotNETCommon/DotNETUtilities/StringUtils.cs
ben marsh d35a845858 Output Visual Studio project files in the same format as Visual Studio, and use StringBuilders everywhere to avoid large numbers of string copies.
#rb none
#jira

#ROBOMERGE-SOURCE: CL 4431637 in //UE4/Release-4.21/...
#ROBOMERGE-BOT: RELEASE (Release-4.21 -> Release-Staging-4.21)

[CL 4431638 by ben marsh in Staging-4.21 branch]
2018-10-05 10:26:06 -04:00

50 lines
1.4 KiB
C#

// Copyright 1998-2018 Epic Games, Inc. All Rights Reserved.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DotNETUtilities
{
public static class StringUtils
{
/// <summary>
/// Extension method to allow formatting a string to a stringbuilder and appending a newline
/// </summary>
/// <param name="Builder">The string builder</param>
/// <param name="Format">Format string, as used for StringBuilder.AppendFormat</param>
/// <param name="Args">Arguments for the format string</param>
public static void AppendLine(this StringBuilder Builder, string Format, params object[] Args)
{
Builder.AppendFormat(Format, Args);
Builder.AppendLine();
}
/// <summary>
/// Case-sensitive replacement for String.EndsWith(), which seems to be pathalogically slow on Mono.
/// </summary>
/// <param name="Source">String to test</param>
/// <param name="Suffix">Suffix to check for</param>
/// <returns>True if the source string ends with the given suffix</returns>
public static bool FastEndsWith(string Source, string Suffix)
{
if(Source.Length < Suffix.Length)
{
return false;
}
int SourceBase = Source.Length - Suffix.Length;
for(int Idx = 0; Idx < Suffix.Length; Idx++)
{
if(Source[SourceBase + Idx] != Suffix[Idx])
{
return false;
}
}
return true;
}
}
}