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

◆ JoinCore() [2/3]

static string System.String.JoinCore ( ReadOnlySpan< char > separator,
ReadOnlySpan< string > values )
inlinestaticprivate

Definition at line 2164 of file String.cs.

2165 {
2166 if (values.Length <= 1)
2167 {
2168 object obj;
2169 if (!values.IsEmpty)
2170 {
2171 obj = values[0];
2172 if (obj == null)
2173 {
2174 return Empty;
2175 }
2176 }
2177 else
2178 {
2179 obj = Empty;
2180 }
2181 return (string)obj;
2182 }
2183 long num = (long)(values.Length - 1) * (long)separator.Length;
2184 if (num > int.MaxValue)
2185 {
2186 ThrowHelper.ThrowOutOfMemoryException();
2187 }
2188 int num2 = (int)num;
2190 for (int i = 0; i < readOnlySpan.Length; i++)
2191 {
2192 string text = readOnlySpan[i];
2193 if ((object)text != null)
2194 {
2195 num2 += text.Length;
2196 if (num2 < 0)
2197 {
2198 ThrowHelper.ThrowOutOfMemoryException();
2199 }
2200 }
2201 }
2202 string text2 = FastAllocateString(num2);
2203 int num3 = 0;
2204 for (int j = 0; j < values.Length; j++)
2205 {
2206 string text3 = values[j];
2207 if ((object)text3 != null)
2208 {
2209 int length = text3.Length;
2210 if (length > num2 - num3)
2211 {
2212 num3 = -1;
2213 break;
2214 }
2216 num3 += length;
2217 }
2218 if (j < values.Length - 1)
2219 {
2220 ref char reference = ref Unsafe.Add(ref text2._firstChar, num3);
2221 if (separator.Length == 1)
2222 {
2223 reference = separator[0];
2224 }
2225 else
2226 {
2228 }
2229 num3 += separator.Length;
2230 }
2231 }
2232 if (num3 != num2)
2233 {
2234 return JoinCore(separator, values.ToArray().AsSpan());
2235 }
2236 return text2;
2237 }
void CopyTo(KeyValuePair< TKey, TValue >[] array, int index)
static string JoinCore(ReadOnlySpan< char > separator, string[] value, int startIndex, int count)
Definition String.cs:2014
static readonly string Empty
Definition String.cs:29
static void FillStringChecked(string dest, int destPos, string src)
Definition String.cs:1560
static string FastAllocateString(int length)

References System.Collections.Generic.Dictionary< TKey, TValue >.CopyTo(), System.String.Empty, System.String.FastAllocateString(), System.String.FillStringChecked(), System.String.JoinCore(), System.length, System.obj, System.text, System.ThrowHelper.ThrowOutOfMemoryException(), and System.values.