]> git.djapps.eu Git - pkg/ggml/sources/llama.cpp/commitdiff
rpc : use unordered_map::reserve and emplace (#18513)
authorChris Rohlf <redacted>
Fri, 2 Jan 2026 10:09:36 +0000 (05:09 -0500)
committerGitHub <redacted>
Fri, 2 Jan 2026 10:09:36 +0000 (12:09 +0200)
ggml/src/ggml-rpc/ggml-rpc.cpp

index 164b39d01e2d89c9e71fd3693a5edb48ad6dfd09..d7c8ad8c16816ad2ff289ba4bc2a76bc62fde243 100644 (file)
@@ -1517,10 +1517,12 @@ bool rpc_server::graph_compute(const std::vector<uint8_t> & input) {
     struct ggml_cgraph * graph = ggml_new_graph_custom(ctx, n_nodes, false);
     graph->n_nodes = n_nodes;
     std::unordered_map<uint64_t, const rpc_tensor*> tensor_ptrs;
+    tensor_ptrs.reserve(n_tensors);
     for (uint32_t i = 0; i < n_tensors; i++) {
-        tensor_ptrs[tensors[i].id] = &tensors[i];
+        tensor_ptrs.emplace(tensors[i].id, &tensors[i]);
     }
     std::unordered_map<uint64_t, ggml_tensor*> tensor_map;
+    tensor_map.reserve(n_nodes);
     for (uint32_t i = 0; i < n_nodes; i++) {
         int64_t id;
         memcpy(&id, &nodes[i], sizeof(id));