minetest-0001: mg_ore.cpp c_wherein vector CONTAINS in voxel inner loop O(V*W) HIGH 3.3x minetest-0002: mg_decoration.cpp c_place_on/c_spawnby vector CONTAINS O(S*P) MEDIUM 1.8x minetest-0003: l_env.cpp find_node_near/find_nodes_in_area filter CONTAINS O(V*F) MEDIUM 1.6x minetest-0004: nodedef.cpp nodeboxConnects sorted vector linear scan O(N) MEDIUM 2.1x minetest-0005: blockmodifier.cpp ABM neighbor check sorted vector O(N) LOW-MEDIUM 1.5x MOAD-0002: g_settings global singleton (architectural, not patchable) MOAD-0003: thread_local log streams (properly scoped, not leaked context) MOAD-0004: CLEAN (no credential logging found) MOAD-0005: CLEAN (no unsynchronized cache patterns found)
80 lines
2.8 KiB
Diff
80 lines
2.8 KiB
Diff
# UNDF: UNDF-2026-000000938
|
|
--- a/src/mapgen/mg_ore.h
|
|
+++ b/src/mapgen/mg_ore.h
|
|
@@ -1,6 +1,7 @@
|
|
#pragma once
|
|
|
|
#include <unordered_set>
|
|
+#include <algorithm>
|
|
#include "objdef.h"
|
|
#include "noise.h"
|
|
#include "nodedef.h"
|
|
@@ -40,7 +41,7 @@ class Ore : public ObjDef, public NodeResolver {
|
|
|
|
content_t c_ore; // the node to place
|
|
- std::vector<content_t> c_wherein; // the nodes to be placed in
|
|
+ std::unordered_set<content_t> c_wherein; // the nodes to be placed in
|
|
u32 clust_scarcity; // ore cluster has a 1-in-clust_scarcity chance of appearing at a node
|
|
s16 clust_num_ores; // how many ore nodes are in a chunk
|
|
s16 clust_size; // how large (in nodes) a chunk of ore is
|
|
--- a/src/mapgen/mg_ore.cpp
|
|
+++ b/src/mapgen/mg_ore.cpp
|
|
@@ -75,7 +75,10 @@ Ore::~Ore()
|
|
|
|
void Ore::resolveNodeNames()
|
|
{
|
|
- getIdsFromNrBacklog(&c_wherein);
|
|
+ std::vector<content_t> c_wherein_vec;
|
|
+ getIdsFromNrBacklog(&c_wherein_vec);
|
|
+ c_wherein.clear();
|
|
+ c_wherein.insert(c_wherein_vec.begin(), c_wherein_vec.end());
|
|
getIdFromNrBacklog(&c_ore, "", CONTENT_AIR);
|
|
}
|
|
|
|
@@ -102,7 +105,7 @@ void Ore::cloneTo(Ore *def) const
|
|
|
|
// All six ore generate() methods: replace CONTAINS(c_wherein, ...) with
|
|
-// c_wherein.count(...) for O(1) lookup instead of O(N) linear scan.
|
|
+// c_wherein.count(...) for O(1) lookup instead of O(N) linear scan:
|
|
|
|
// OreScatter::generate
|
|
@@ -165,7 +168,7 @@ void OreScatter::generate(...)
|
|
u32 i = vm->m_area.index(x0 + x1, y0 + y1, z0 + z1);
|
|
- if (!CONTAINS(c_wherein, vm->m_data[i].getContent()))
|
|
+ if (c_wherein.count(vm->m_data[i].getContent()) == 0)
|
|
continue;
|
|
|
|
// OreSheet::generate
|
|
@@ -234,7 +237,7 @@ void OreSheet::generate(...)
|
|
u32 i = vm->m_area.index(x, y, z);
|
|
- if (!CONTAINS(c_wherein, vm->m_data[i].getContent()))
|
|
+ if (c_wherein.count(vm->m_data[i].getContent()) == 0)
|
|
continue;
|
|
|
|
// OrePuff::generate
|
|
@@ -328,7 +331,7 @@ void OrePuff::generate(...)
|
|
u32 i = vm->m_area.index(x, y, z);
|
|
- if (!CONTAINS(c_wherein, vm->m_data[i].getContent()))
|
|
+ if (c_wherein.count(vm->m_data[i].getContent()) == 0)
|
|
continue;
|
|
|
|
// OreBlob::generate
|
|
@@ -384,7 +387,7 @@ void OreBlob::generate(...)
|
|
u32 i = vm->m_area.index(x0 + x1, y0 + y1, z0 + z1);
|
|
- if (!CONTAINS(c_wherein, vm->m_data[i].getContent()))
|
|
+ if (c_wherein.count(vm->m_data[i].getContent()) == 0)
|
|
continue;
|
|
|
|
// OreVein::generate
|
|
@@ -463,7 +466,7 @@ void OreVein::generate(...)
|
|
u32 i = vm->m_area.index(x, y, z);
|
|
- if (!CONTAINS(c_wherein, vm->m_data[i].getContent()))
|
|
+ if (c_wherein.count(vm->m_data[i].getContent()) == 0)
|
|
continue;
|
|
|
|
// OreStratum::generate
|
|
@@ -574,7 +577,7 @@ void OreStratum::generate(...)
|
|
u32 i = vm->m_area.index(x, y, z);
|
|
- if (!CONTAINS(c_wherein, vm->m_data[i].getContent()))
|
|
+ if (c_wherein.count(vm->m_data[i].getContent()) == 0)
|
|
continue;
|