Files
UnrealEngineUWP/Engine/Source/Programs/DotNETCommon/DotNETUtilities/StringUtils.cs
Marc Audy 7a0f229e8d Copying //UE4/Fortnite-Staging to //UE4/Dev-Main (Source: //Fortnite/Main/Engine @ 3876564)
#lockdown Nick.Penwarden
#rnx
#rb none

[CL 3903710 by Marc Audy in Main branch]
2018-02-22 11:25:06 -05:00

38 lines
912 B
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>
/// 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;
}
}
}