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

◆ IndexOf< T >() [2/2]

static int System.SpanHelpers.IndexOf< T > ( ref T searchSpace,
T value,
int length )
inlinestatic
Type Constraints
T :IEquatable<T> 

Definition at line 3034 of file SpanHelpers.cs.

3035 {
3036 nint num = 0;
3037 if (default(T) != null || value != null)
3038 {
3039 while (length >= 8)
3040 {
3041 length -= 8;
3042 if (value.Equals(Unsafe.Add(ref searchSpace, num)))
3043 {
3044 goto IL_021a;
3045 }
3046 if (value.Equals(Unsafe.Add(ref searchSpace, num + 1)))
3047 {
3048 goto IL_021d;
3049 }
3050 if (value.Equals(Unsafe.Add(ref searchSpace, num + 2)))
3051 {
3052 goto IL_0223;
3053 }
3054 if (!value.Equals(Unsafe.Add(ref searchSpace, num + 3)))
3055 {
3056 if (!value.Equals(Unsafe.Add(ref searchSpace, num + 4)))
3057 {
3058 if (!value.Equals(Unsafe.Add(ref searchSpace, num + 5)))
3059 {
3060 if (!value.Equals(Unsafe.Add(ref searchSpace, num + 6)))
3061 {
3062 if (!value.Equals(Unsafe.Add(ref searchSpace, num + 7)))
3063 {
3064 num += 8;
3065 continue;
3066 }
3067 return (int)(num + 7);
3068 }
3069 return (int)(num + 6);
3070 }
3071 return (int)(num + 5);
3072 }
3073 return (int)(num + 4);
3074 }
3075 goto IL_0229;
3076 }
3077 if (length >= 4)
3078 {
3079 length -= 4;
3080 if (value.Equals(Unsafe.Add(ref searchSpace, num)))
3081 {
3082 goto IL_021a;
3083 }
3084 if (value.Equals(Unsafe.Add(ref searchSpace, num + 1)))
3085 {
3086 goto IL_021d;
3087 }
3088 if (value.Equals(Unsafe.Add(ref searchSpace, num + 2)))
3089 {
3090 goto IL_0223;
3091 }
3092 if (value.Equals(Unsafe.Add(ref searchSpace, num + 3)))
3093 {
3094 goto IL_0229;
3095 }
3096 num += 4;
3097 }
3098 while (length > 0)
3099 {
3100 if (!value.Equals(Unsafe.Add(ref searchSpace, num)))
3101 {
3102 num++;
3103 length--;
3104 continue;
3105 }
3106 goto IL_021a;
3107 }
3108 }
3109 else
3110 {
3111 nint num2 = length;
3112 num = 0;
3113 while (num < num2)
3114 {
3115 if (Unsafe.Add(ref searchSpace, num) != null)
3116 {
3117 num++;
3118 continue;
3119 }
3120 goto IL_021a;
3121 }
3122 }
3123 return -1;
3124 IL_021a:
3125 return (int)num;
3126 IL_021d:
3127 return (int)(num + 1);
3128 IL_0229:
3129 return (int)(num + 3);
3130 IL_0223:
3131 return (int)(num + 2);
3132 }

References System.length, and System.value.