#include "common/ceph_json.h"
#include "include/utime.h"
-#include <boost/algorithm/string.hpp>
+#include <include/types.h>
#include <boost/tokenizer.hpp>
#include <boost/lexical_cast.hpp>
-#include <include/types.h>
+#include <boost/algorithm/string.hpp>
+#include <boost/container/flat_map.hpp>
/* Enable boost.json's header-only mode:
(see: "https://github.com/boostorg/json?tab=readme-ov-file#header-only"): */
if (auto op = v.if_object()) {
for (const auto& kvp : *op) {
auto child = std::make_unique<JSONObj>(this, kvp.key(), kvp.value());
- children.insert(std::pair { kvp.key(), std::move(child) });
+ children.emplace(std::pair { kvp.key(), std::move(child) });
}
return;
if (auto ap = v.if_array()) {
for (const auto& kvp : *ap) {
auto child = std::make_unique<JSONObj>(this, "", kvp);
- children.insert(std::pair { child->get_name(), std::move(child) });
+ children.emplace(std::pair { child->get_name(), std::move(child) });
}
}
class JSONObjIter final {
- using map_iter_t = std::map<std::string, std::unique_ptr<JSONObj>, std::less<>>::iterator;
+ using map_iter_t = boost::container::flat_map<std::string, std::unique_ptr<JSONObj>, std::less<>>::iterator;
map_iter_t cur;
map_iter_t last;
{
JSONObj *parent = nullptr;
-protected:
- using children_multimap_t = std::multimap<std::string, std::unique_ptr<JSONObj>, std::less<>>;
- using children_multimap_value_type = typename children_multimap_t::value_type;
-
public:
struct data_val {
std::string str;
bool data_quoted{false};
- children_multimap_t children;
- std::map<std::string, data_val, std::less<>> attr_map;
+ boost::container::flat_multimap<std::string, std::unique_ptr<JSONObj>, std::less<>> children;
+ boost::container::flat_map<std::string, data_val, std::less<>> attr_map;
void handle_value(boost::json::value v);
};
private:
- std::map<std::type_index, HandlerBase *> handlers;
+ boost::container::flat_map<std::type_index, HandlerBase *> handlers;
public:
void register_type(HandlerBase *h) {