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

◆ Compress() [2/2]

static int System.Uri.Compress ( Span< char > span,
UriParser syntax )
inlinestaticprivate

Definition at line 3305 of file Uri.cs.

3306 {
3307 int num = 0;
3308 int num2 = 0;
3309 int num3 = 0;
3310 int num4 = 0;
3311 for (int num5 = span.Length - 1; num5 >= 0; num5--)
3312 {
3313 char c = span[num5];
3314 if (c == '\\' && syntax.InFact(UriSyntaxFlags.ConvertPathSlashes))
3315 {
3316 c = (span[num5] = '/');
3317 }
3318 if (c == '/')
3319 {
3320 num++;
3321 }
3322 else
3323 {
3324 if (num > 1)
3325 {
3326 num2 = num5 + 1;
3327 }
3328 num = 0;
3329 }
3330 if (c == '.')
3331 {
3332 num3++;
3333 continue;
3334 }
3335 if (num3 != 0)
3336 {
3337 if ((!syntax.NotAny(UriSyntaxFlags.CanonicalizeAsFilePath) || (num3 <= 2 && c == '/')) && c == '/' && (num2 == num5 + num3 + 1 || (num2 == 0 && num5 + num3 + 1 == span.Length)) && num3 <= 2)
3338 {
3339 num2 = num5 + 1 + num3 + ((num2 != 0) ? 1 : 0);
3340 span.Slice(num2).CopyTo(span.Slice(num5 + 1));
3341 span = span.Slice(0, span.Length - (num2 - num5 - 1));
3342 num2 = num5;
3343 if (num3 == 2)
3344 {
3345 num4++;
3346 }
3347 num3 = 0;
3348 continue;
3349 }
3350 num3 = 0;
3351 }
3352 if (c == '/')
3353 {
3354 if (num4 != 0)
3355 {
3356 num4--;
3357 span.Slice(num2 + 1).CopyTo(span.Slice(num5 + 1));
3358 span = span.Slice(0, span.Length - (num2 - num5));
3359 }
3360 num2 = num5;
3361 }
3362 }
3363 if (span.Length != 0 && syntax.InFact(UriSyntaxFlags.CanonicalizeAsFilePath) && num <= 1)
3364 {
3365 if (num4 != 0 && span[0] != '/')
3366 {
3367 num2++;
3368 span.Slice(num2).CopyTo(span);
3369 return span.Length - num2;
3370 }
3371 if (num3 != 0 && (num2 == num3 || (num2 == 0 && num3 == span.Length)))
3372 {
3373 num3 += ((num2 != 0) ? 1 : 0);
3374 span.Slice(num3).CopyTo(span);
3375 return span.Length - num3;
3376 }
3377 }
3378 return span.Length;
3379 }
void CopyTo(KeyValuePair< TKey, TValue >[] array, int index)

References System.Collections.Generic.Dictionary< TKey, TValue >.CopyTo(), and System.Runtime.Serialization.Dictionary.