diff --git a/troposphere/haze/include/haze/ptp_object_database.hpp b/troposphere/haze/include/haze/ptp_object_database.hpp index c2becaec6..24001a8c3 100644 --- a/troposphere/haze/include/haze/ptp_object_database.hpp +++ b/troposphere/haze/include/haze/ptp_object_database.hpp @@ -50,7 +50,9 @@ namespace haze { template requires (std::same_as || std::same_as) static constexpr int Compare(const T &lhs, const PtpObject &rhs) { - return std::strcmp(lhs.GetName(), rhs.GetName()); + /* All SD card filesystems supported by fs are case-insensitive and case-preserving. */ + /* Account for that in collation here. */ + return strcasecmp(lhs.GetName(), rhs.GetName()); } }; diff --git a/troposphere/haze/source/ptp_object_database.cpp b/troposphere/haze/source/ptp_object_database.cpp index a8b4d2117..7e71a307b 100644 --- a/troposphere/haze/source/ptp_object_database.cpp +++ b/troposphere/haze/source/ptp_object_database.cpp @@ -134,21 +134,19 @@ namespace haze { PtpObject *PtpObjectDatabase::GetObjectById(u32 object_id) { /* Find in ID mapping. */ - auto it = m_object_id_tree.find_key(object_id); - if (it == m_object_id_tree.end()) { + if (auto it = m_object_id_tree.find_key(object_id); it != m_object_id_tree.end()) { + return std::addressof(*it); + } else { return nullptr; } - - return std::addressof(*it); } PtpObject *PtpObjectDatabase::GetObjectByName(const char *name) { /* Find in name mapping. */ - auto it = m_name_tree.find_key(name); - if (it == m_name_tree.end()) { + if (auto it = m_name_tree.find_key(name); it != m_name_tree.end()) { + return std::addressof(*it); + } else { return nullptr; } - - return std::addressof(*it); } }