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

◆ Replace() [1/4]

string System.String.Replace ( char oldChar,
char newChar )
inline

Definition at line 2389 of file String.cs.

2390 {
2391 if (oldChar == newChar)
2392 {
2393 return this;
2394 }
2395 int num = IndexOf(oldChar);
2396 if (num < 0)
2397 {
2398 return this;
2399 }
2400 int num2 = Length - num;
2401 string text = FastAllocateString(Length);
2402 int num3 = num;
2403 if (num3 > 0)
2404 {
2405 Buffer.Memmove(ref text._firstChar, ref _firstChar, (uint)num3);
2406 }
2407 ref ushort reference = ref Unsafe.Add(ref Unsafe.As<char, ushort>(ref _firstChar), num3);
2408 ref ushort reference2 = ref Unsafe.Add(ref Unsafe.As<char, ushort>(ref text._firstChar), num3);
2410 {
2413 do
2414 {
2415 Vector<ushort> vector = Unsafe.ReadUnaligned<Vector<ushort>>(ref Unsafe.As<ushort, byte>(ref reference));
2416 Vector<ushort> condition = Vector.Equals(vector, right);
2418 Unsafe.WriteUnaligned(ref Unsafe.As<ushort, byte>(ref reference2), value);
2422 }
2423 while (num2 >= Vector<ushort>.Count);
2424 }
2425 while (num2 > 0)
2426 {
2427 ushort num4 = reference;
2428 reference2 = ((num4 == oldChar) ? newChar : num4);
2429 reference = ref Unsafe.Add(ref reference, 1);
2431 num2--;
2432 }
2433 return text;
2434 }
static Vector< float > ConditionalSelect(Vector< int > condition, Vector< float > left, Vector< float > right)
Definition Vector.cs:24
static bool IsHardwareAccelerated
Definition Vector.cs:14
static Vector< int > Equals(Vector< float > left, Vector< float > right)
Definition Vector.cs:52
char _firstChar
Definition String.cs:35
int IndexOf(char value)
Definition String.cs:3228
static string FastAllocateString(int length)

References System.String._firstChar, System.Numerics.Vector< T >.ConditionalSelect(), System.Collections.Generic.Dictionary< TKey, TValue >.Count, System.Numerics.Vector< T >.Equals(), System.String.FastAllocateString(), System.String.IndexOf(), System.Numerics.Vector< T >.IsHardwareAccelerated, System.String.Length, System.Buffer.Memmove(), System.text, and System.value.