Index: source/Utility/FileSpec.cpp =================================================================== --- source/Utility/FileSpec.cpp +++ source/Utility/FileSpec.cpp @@ -404,8 +404,30 @@ // case sensitivity of equality test const bool case_sensitive = a.IsCaseSensitive() || b.IsCaseSensitive(); + // First test for filename inequality since that is cheap. + // The only case where the filenames might be unequal but GetNormalizedPath + // will resolve to equal paths is if the filename component of one or + // the other FileSpec's is "." or "..", and then only if remove_backups + // is true. + + static ConstString g_dot_string("."); + static ConstString g_dot_dot_string(".."); + + bool filenames_equal = ConstString::Equals(a.m_filename, + b.m_filename, + case_sensitive); + bool last_component_is_dot = ConstString::Equals(a.m_filename, g_dot_string) + || ConstString::Equals(a.m_filename, + g_dot_dot_string) + || ConstString::Equals(b.m_filename, + g_dot_string) + || ConstString::Equals(b.m_filename, + g_dot_dot_string); + if (!filenames_equal && !(remove_backups || last_component_is_dot)) + return false; + if (!full && (a.GetDirectory().IsEmpty() || b.GetDirectory().IsEmpty())) - return ConstString::Equals(a.m_filename, b.m_filename, case_sensitive); + return filenames_equal; if (remove_backups == false) return a == b;