|
@@ -1,3 +1,5 @@
|
|
|
|
|
+using System.Runtime.CompilerServices;
|
|
|
|
|
+
|
|
|
namespace Lua.Standard.Text;
|
|
namespace Lua.Standard.Text;
|
|
|
|
|
|
|
|
internal static class StringHelper
|
|
internal static class StringHelper
|
|
@@ -7,4 +9,16 @@ internal static class StringHelper
|
|
|
if (i >= 0 && i <= 255) return i;
|
|
if (i >= 0 && i <= 255) return i;
|
|
|
throw new ArgumentOutOfRangeException(nameof(i));
|
|
throw new ArgumentOutOfRangeException(nameof(i));
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
|
|
|
+ public static string SubString(string s, int i, int j)
|
|
|
|
|
+ {
|
|
|
|
|
+ if (i < 0) i = s.Length + i + 1;
|
|
|
|
|
+ if (j < 0) i = s.Length + i + 1;
|
|
|
|
|
+
|
|
|
|
|
+ if (i < 1) i = 1;
|
|
|
|
|
+ if (j > s.Length) j = s.Length;
|
|
|
|
|
+
|
|
|
|
|
+ return i > j ? "" : s.Substring(i - 1, j - 1);
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|