[lldb] refactor FileSpec::Equal

The logic of this function was quite hard to follow. Replace it with a
much simpler, equivalent, implementation.
This commit is contained in:
Pavel Labath 2019-11-28 13:48:05 +01:00
parent bf716eb807
commit b18e190b7c
1 changed files with 3 additions and 13 deletions

View File

@ -302,20 +302,10 @@ int FileSpec::Compare(const FileSpec &a, const FileSpec &b, bool full) {
}
bool FileSpec::Equal(const FileSpec &a, const FileSpec &b, bool full) {
// case sensitivity of equality test
const bool case_sensitive = a.IsCaseSensitive() || b.IsCaseSensitive();
if (full || (a.GetDirectory() && b.GetDirectory()))
return a == b;
const bool filenames_equal = ConstString::Equals(a.m_filename,
b.m_filename,
case_sensitive);
if (!filenames_equal)
return false;
if (!full && (a.GetDirectory().IsEmpty() || b.GetDirectory().IsEmpty()))
return filenames_equal;
return a == b;
return a.FileEquals(b);
}
llvm::Optional<FileSpec::Style> FileSpec::GuessPathStyle(llvm::StringRef absolute_path) {