MCPcopy Create free account
hub / github.com/Codeya-IDE/deepin-ide / match_main

Method match_main

3rdparty/diff-match-patch/diff_match_patch.cpp:1425–1447  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1423
1424
1425int diff_match_patch::match_main(const QString &text, const QString &pattern,
1426 int loc) {
1427 // Check for null inputs.
1428 if (text.isNull() || pattern.isNull()) {
1429 throw "Null inputs. (match_main)";
1430 }
1431
1432 loc = std::max(0, std::min(loc, text.length()));
1433 if (text == pattern) {
1434 // Shortcut (potentially not guaranteed by the algorithm)
1435 return 0;
1436 } else if (text.isEmpty()) {
1437 // Nothing to match.
1438 return -1;
1439 } else if (loc + pattern.length() <= text.length()
1440 && safeMid(text, loc, pattern.length()) == pattern) {
1441 // Perfect match at the perfect spot! (Includes case of null pattern)
1442 return loc;
1443 } else {
1444 // Do a fuzzy compare.
1445 return match_bitap(text, pattern, loc);
1446 }
1447}
1448
1449
1450int diff_match_patch::match_bitap(const QString &text, const QString &pattern,

Callers

nothing calls this directly

Calls 3

isNullMethod · 0.45
lengthMethod · 0.45
isEmptyMethod · 0.45

Tested by

no test coverage detected