You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: nanoFramework.CoreLibrary/System/Guid.cs
+43-8Lines changed: 43 additions & 8 deletions
Original file line number
Diff line number
Diff line change
@@ -176,22 +176,57 @@ public int CompareTo(object value)
176
176
/// <summary>
177
177
/// Compares the current instance with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other object.
178
178
/// </summary>
179
-
/// <param name="other">An object to compare with this instance.</param>
179
+
/// <param name="value">An object to compare with this instance.</param>
180
180
/// <returns>A value that indicates the relative order of the objects being compared.</returns>
181
-
publicintCompareTo(Guidother)
181
+
publicintCompareTo(Guidvalue)
182
182
{
183
183
_data??=newint[4];
184
-
other._data??=newint[4];
185
-
for(inti=0;i<4;i++)
184
+
value._data??=newint[4];
185
+
186
+
uintthis0=(uint)_data[0];
187
+
uintother0=(uint)value._data[0];
188
+
if(this0!=other0)
186
189
{
187
-
if(_data[i]!=other._data[i])
188
-
{
189
-
return_data[i]-other._data[i];
190
-
}
190
+
returnthis0<other0?-1:1;
191
+
}
192
+
193
+
uintthis1=SwapHalves((uint)_data[1]);
194
+
uintother1=SwapHalves((uint)value._data[1]);
195
+
if(this1!=other1)
196
+
{
197
+
returnthis1<other1?-1:1;
198
+
}
199
+
200
+
uintthis2=SwapBytes((uint)_data[2]);
201
+
uintother2=SwapBytes((uint)value._data[2]);
202
+
if(this2!=other2)
203
+
{
204
+
returnthis2<other2?-1:1;
191
205
}
206
+
207
+
uintthis3=SwapBytes((uint)_data[3]);
208
+
uintother3=SwapBytes((uint)value._data[3]);
209
+
if(this3!=other3)
210
+
{
211
+
returnthis3<other3?-1:1;
212
+
}
213
+
192
214
return0;
193
215
}
194
216
217
+
privatestaticuintSwapHalves(uintvalue)
218
+
{
219
+
return(value<<16)|(value>>16);
220
+
}
221
+
222
+
privatestaticuintSwapBytes(uintvalue)
223
+
{
224
+
return((value&0x000000FFu)<<24)|
225
+
((value&0x0000FF00u)<<8)|
226
+
((value&0x00FF0000u)>>8)|
227
+
((value&0xFF000000u)>>24);
228
+
}
229
+
195
230
/// <summary>
196
231
/// Returns a 16-element byte array that contains the value of this instance.
0 commit comments