Stop path scoring at the first component mismatch

This commit is contained in:
Jean Pierre Cimalando 2020-10-30 08:36:52 +01:00
parent 73051b7135
commit e254fe021d

View file

@ -155,7 +155,8 @@ const fs::path& SfzFileScan::electBestMatch(const fs::path& path, absl::Span<con
auto it1 = p1.end();
auto it2 = p2.end();
while (it1-- != p1.begin() && it2-- != p2.begin()) {
bool matching = true;
while (matching && it1-- != p1.begin() && it2-- != p2.begin()) {
const fs::path& c1 = *it1;
const fs::path& c2 = *it2;
if (c1 == c2) {
@ -164,6 +165,8 @@ const fs::path& SfzFileScan::electBestMatch(const fs::path& path, absl::Span<con
}
else if (SfzFileScanImpl::asciiCaseEqual(c1.native(), c2.native()))
score.components += 1;
else
matching = false;
}
}