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

Method preprocess1AndDiff

src/plugins/git/utils/differ.cpp:966–1000  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

964}
965
966QList<Diff> Differ::preprocess1AndDiff(const QString &text1, const QString &text2)
967{
968 if (text1.isNull() && text2.isNull())
969 return {};
970
971 if (text1 == text2) {
972 QList<Diff> diffList;
973 if (!text1.isEmpty())
974 diffList.append(Diff(Diff::Equal, text1));
975 return diffList;
976 }
977
978 QString newText1 = text1;
979 QString newText2 = text2;
980 QString prefix;
981 QString suffix;
982 const int prefixCount = commonPrefix(text1, text2);
983 if (prefixCount) {
984 prefix = text1.left(prefixCount);
985 newText1 = text1.mid(prefixCount);
986 newText2 = text2.mid(prefixCount);
987 }
988 const int suffixCount = commonSuffix(newText1, newText2);
989 if (suffixCount) {
990 suffix = newText1.right(suffixCount);
991 newText1 = newText1.left(newText1.size() - suffixCount);
992 newText2 = newText2.left(newText2.size() - suffixCount);
993 }
994 QList<Diff> diffList = preprocess2AndDiff(newText1, newText2);
995 if (prefixCount)
996 diffList.prepend(Diff(Diff::Equal, prefix));
997 if (suffixCount)
998 diffList.append(Diff(Diff::Equal, suffix));
999 return diffList;
1000}
1001
1002QList<Diff> Differ::preprocess2AndDiff(const QString &text1, const QString &text2)
1003{

Callers

nothing calls this directly

Calls 9

commonPrefixFunction · 0.85
commonSuffixFunction · 0.85
leftMethod · 0.80
rightMethod · 0.80
DiffClass · 0.50
isNullMethod · 0.45
isEmptyMethod · 0.45
appendMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected