Skip to content

Commit 6424cd7

Browse files
committed
refactor GetNamespace to standardize variable naming and streamline key handling
1 parent 397dcb0 commit 6424cd7

1 file changed

Lines changed: 4 additions & 6 deletions

File tree

modules/core/util/include/util.hpp

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -52,15 +52,14 @@ template <typename T>
5252
constexpr std::string_view GetNamespace() {
5353
#ifdef _MSC_VER
5454
constexpr std::string_view kFunc{__FUNCSIG__};
55-
constexpr std::string_view key = "GetNamespace<";
55+
constexpr std::string_view kKey = "GetNamespace<";
5656
#else
5757
constexpr std::string_view kFunc{__PRETTY_FUNCTION__};
58-
constexpr std::string_view key = "T = ";
58+
constexpr std::string_view kKey = "T = ";
5959
#endif
6060

61-
auto start = kFunc.find(key);
62-
if (start == std::string_view::npos) return {};
63-
start += key.size();
61+
auto start = kFunc.find(kKey);
62+
start = (start == std::string_view::npos) ? kFunc.size() : start + kKey.size();
6463

6564
for (auto p : {"class ", "struct ", "enum ", "union "})
6665
if (kFunc.substr(start).starts_with(p)) start += std::string_view{p}.size();
@@ -70,7 +69,6 @@ constexpr std::string_view GetNamespace() {
7069
return (pos != std::string_view::npos) ? ns_type.substr(0, pos) : std::string_view{};
7170
}
7271

73-
7472
inline std::shared_ptr<nlohmann::json> InitJSONPtr() { return std::make_shared<nlohmann::json>(); }
7573

7674
bool IsUnderMpirun();

0 commit comments

Comments
 (0)