MCPcopy Create free account
hub / github.com/HaxeFoundation/hxcpp / lastIndexOf

Method lastIndexOf

src/String.cpp:1362–1392  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1360
1361
1362int String::lastIndexOf(const String &inValue, Dynamic inStart) const
1363{
1364 if (__s==0)
1365 return -1;
1366 int l = inValue.length;
1367 int s = inStart==null() ? length : inStart->__ToInt();
1368 if (l==0) {
1369 return std::max(0, std::min(s, length));
1370 }
1371 if (l>length) return -1;
1372 if (s+l>length) s = length-l;
1373
1374 #ifdef HX_SMART_STRINGS
1375 bool s016 = isUTF16Encoded();
1376 bool s116 = inValue.isUTF16Encoded();
1377 if (s016 || s116)
1378 {
1379 if (s016 && s116)
1380 return TLastIndexOf(s, __w, length, inValue.__w, inValue.length);
1381
1382 while(s>=0)
1383 {
1384 if (s016 ? StrMatch(__w+s, inValue.__s, l) : StrMatch(inValue.__w, __s+s, l) )
1385 return s;
1386 s--;
1387 }
1388 return -1;
1389 }
1390 #endif
1391 return TLastIndexOf(s, __s, length, inValue.__s, inValue.length);
1392}
1393
1394
1395

Callers 5

runLastIndexOfMethod · 0.80
runIntMethod · 0.80
runIndexMethod · 0.80
runIntMethod · 0.80
runLastIndexOfMethod · 0.80

Calls 7

maxFunction · 0.85
minFunction · 0.85
isUTF16EncodedFunction · 0.85
TLastIndexOfFunction · 0.85
StrMatchFunction · 0.85
nullClass · 0.50
__ToIntMethod · 0.45

Tested by

no test coverage detected