using System.Collections.Generic;
namespace MLEM.Extensions {
///
/// A set of extensions for dealing with
///
public static class CharExtensions {
private static readonly Dictionary Cache = new Dictionary();
///
/// Returns the string representation of this character which will be stored and retrieved from a dictionary cache.
/// This method reduces string allocations, making it trade in processor efficiency for memory efficiency.
///
/// The character to turn into a string
/// A string representing the character
public static string ToCachedString(this char c) {
if (!Cache.TryGetValue(c, out var ret)) {
ret = c.ToString();
Cache.Add(c, ret);
}
return ret;
}
}
}