MCPcopy Create free account
hub / github.com/beefytech/Beef / CompareOrdinalIgnoreCaseHelper

Method CompareOrdinalIgnoreCaseHelper

BeefySysLib/util/String.cpp:372–403  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

370}
371
372int StringImpl::CompareOrdinalIgnoreCaseHelper(const StringImpl & strA, const StringImpl & strB)
373{
374 /*Contract.Requires(strA != null);
375 Contract.Requires(strB != null);
376 Contract.EndContractBlock();*/
377 int_strsize length = BF_MIN(strA.mLength, strB.mLength);
378
379 const char* a = strA.GetPtr();
380 const char* b = strB.GetPtr();
381
382 while (length != 0)
383 {
384 int_strsize char8A = (int_strsize)*a;
385 int_strsize char8B = (int_strsize)*b;
386
387 //Contract.Assert((char8A | char8B) <= 0x7F, "strings have to be ASCII");
388
389 // uppercase both char8s - notice that we need just one compare per char8
390 if ((uint32)(char8A - 'a') <= (uint32)('z' - 'a')) char8A -= 0x20;
391 if ((uint32)(char8B - 'a') <= (uint32)('z' - 'a')) char8B -= 0x20;
392
393 //Return the (case-insensitive) difference between them.
394 if (char8A != char8B)
395 return char8A - char8B;
396
397 // Next char8
398 a++; b++;
399 length--;
400 }
401
402 return strA.mLength - strB.mLength;
403}
404
405intptr StringImpl::CompareOrdinalIgnoreCaseHelper(const char * strA, intptr lengthA, const char * strB, intptr lengthB)
406{

Callers

nothing calls this directly

Calls 1

GetPtrMethod · 0.45

Tested by

no test coverage detected