From ae96d2fbca505f4c59f620623c98a760e8484bd3 Mon Sep 17 00:00:00 2001 From: k0zmo Date: Sat, 18 Jul 2020 21:20:33 +0200 Subject: [PATCH] Don't create a temporary string when comparing a const char* key --- include/yaml-cpp/node/detail/impl.h | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/include/yaml-cpp/node/detail/impl.h b/include/yaml-cpp/node/detail/impl.h index a94c7bc..b38038d 100644 --- a/include/yaml-cpp/node/detail/impl.h +++ b/include/yaml-cpp/node/detail/impl.h @@ -106,7 +106,11 @@ inline bool node::equals(const T& rhs, shared_memory_holder pMemory) { } inline bool node::equals(const char* rhs, shared_memory_holder pMemory) { - return equals(rhs, pMemory); + std::string lhs; + if (convert::decode(Node(*this, std::move(pMemory)), lhs)) { + return lhs == rhs; + } + return false; } // indexing