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

◆ Ctor() [3/9]

unsafe string System.String.Ctor ( char c,
int count )
inlineprivate

Definition at line 1112 of file String.cs.

1113 {
1114 if (count <= 0)
1115 {
1116 if (count == 0)
1117 {
1118 return Empty;
1119 }
1120 throw new ArgumentOutOfRangeException("count", SR.ArgumentOutOfRange_NegativeCount);
1121 }
1122 string text = FastAllocateString(count);
1123 if (c != 0)
1124 {
1125 fixed (char* ptr = &text._firstChar)
1126 {
1127 uint num = ((uint)c << 16) | c;
1128 uint* ptr2 = (uint*)ptr;
1129 if (count >= 4)
1130 {
1131 count -= 4;
1132 do
1133 {
1134 *ptr2 = num;
1135 ptr2[1] = num;
1136 ptr2 += 2;
1137 count -= 4;
1138 }
1139 while (count >= 0);
1140 }
1141 if (((uint)count & 2u) != 0)
1142 {
1143 *ptr2 = num;
1144 ptr2++;
1145 }
1146 if (((uint)count & (true ? 1u : 0u)) != 0)
1147 {
1148 *(char*)ptr2 = c;
1149 }
1150 }
1151 }
1152 return text;
1153 }
static readonly string Empty
Definition String.cs:29
static string FastAllocateString(int length)

References System.SR.ArgumentOutOfRange_NegativeCount, System.count, System.String.Empty, System.String.FastAllocateString(), and System.text.