Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches

◆ ReplaceHelper()

string System.String.ReplaceHelper ( int oldValueLength,
string newValue,
ReadOnlySpan< int > indices )
inlineprivate

Definition at line 2494 of file String.cs.

2495 {
2496 long num = Length + (long)(newValue.Length - oldValueLength) * (long)indices.Length;
2497 if (num > int.MaxValue)
2498 {
2499 throw new OutOfMemoryException();
2500 }
2501 string text = FastAllocateString((int)num);
2502 Span<char> span = new Span<char>(ref text._firstChar, text.Length);
2503 int num2 = 0;
2504 int num3 = 0;
2505 for (int i = 0; i < indices.Length; i++)
2506 {
2507 int num4 = indices[i];
2508 int num5 = num4 - num2;
2509 if (num5 != 0)
2510 {
2511 this.AsSpan(num2, num5).CopyTo(span.Slice(num3));
2512 num3 += num5;
2513 }
2515 newValue.CopyTo(span.Slice(num3));
2516 num3 += newValue.Length;
2517 }
2518 this.AsSpan(num2).CopyTo(span.Slice(num3));
2519 return text;
2520 }
void CopyTo(KeyValuePair< TKey, TValue >[] array, int index)
static string FastAllocateString(int length)

References System.Collections.Generic.Dictionary< TKey, TValue >.CopyTo(), System.String.FastAllocateString(), System.indices, System.String.Length, and System.text.

Referenced by System.String.Replace().