Commit dca5927ba0e57c7046a93213e05bfa6eda130707
1 parent
b85a590b
Tweak Handlers::json_handlers
Use std::vector instead of list and move shared pointers
Showing
1 changed file
with
6 additions
and
4 deletions
libqpdf/QPDFJob_json.cc
| ... | ... | @@ -59,7 +59,7 @@ namespace |
| 59 | 59 | |
| 60 | 60 | void beginUnderOverlay(JSON const& j); |
| 61 | 61 | |
| 62 | - std::list<std::shared_ptr<JSONHandler>> json_handlers; | |
| 62 | + std::vector<std::shared_ptr<JSONHandler>> json_handlers; | |
| 63 | 63 | bool partial; |
| 64 | 64 | JSONHandler* jh{nullptr}; // points to last of json_handlers |
| 65 | 65 | std::shared_ptr<QPDFJob::Config> c_main; |
| ... | ... | @@ -100,7 +100,7 @@ Handlers::bindJSON(void (Handlers::*f)(JSON)) |
| 100 | 100 | void |
| 101 | 101 | Handlers::initHandlers() |
| 102 | 102 | { |
| 103 | - this->json_handlers.push_back(std::make_shared<JSONHandler>()); | |
| 103 | + this->json_handlers.emplace_back(std::make_shared<JSONHandler>()); | |
| 104 | 104 | this->jh = this->json_handlers.back().get(); |
| 105 | 105 | jh->addDictHandlers( |
| 106 | 106 | [](std::string const&, JSON) {}, |
| ... | ... | @@ -184,8 +184,9 @@ Handlers::pushKey(std::string const& key) |
| 184 | 184 | { |
| 185 | 185 | auto new_jh = std::make_shared<JSONHandler>(); |
| 186 | 186 | this->jh->addDictKeyHandler(key, new_jh); |
| 187 | - this->json_handlers.push_back(new_jh); | |
| 188 | 187 | this->jh = new_jh.get(); |
| 188 | + this->json_handlers.emplace_back(std::move(new_jh)); | |
| 189 | + | |
| 189 | 190 | } |
| 190 | 191 | |
| 191 | 192 | void |
| ... | ... | @@ -205,8 +206,9 @@ Handlers::beginArray(json_handler_t start_fn, bare_handler_t end_fn) |
| 205 | 206 | [end_fn](std::string const&) { end_fn(); }, |
| 206 | 207 | item_jh); |
| 207 | 208 | jh->addFallbackHandler(item_jh); |
| 208 | - this->json_handlers.push_back(item_jh); | |
| 209 | 209 | this->jh = item_jh.get(); |
| 210 | + this->json_handlers.emplace_back(std::move(item_jh)); | |
| 211 | + | |
| 210 | 212 | } |
| 211 | 213 | |
| 212 | 214 | void | ... | ... |