Huge LBM lookup performance improvement on mapblock loading (#7195)
* Huge LBM lookup performance improvement on mapblock loading
This commit is contained in:
parent
fe41725e50
commit
396daf1be1
|
@ -262,16 +262,25 @@ void LBMManager::applyLBMs(ServerEnvironment *env, MapBlock *block, u32 stamp)
|
||||||
MapNode n;
|
MapNode n;
|
||||||
content_t c;
|
content_t c;
|
||||||
lbm_lookup_map::const_iterator it = getLBMsIntroducedAfter(stamp);
|
lbm_lookup_map::const_iterator it = getLBMsIntroducedAfter(stamp);
|
||||||
|
for (; it != m_lbm_lookup.end(); ++it) {
|
||||||
|
// Cache previous version to speedup lookup which has a very high performance
|
||||||
|
// penalty on each call
|
||||||
|
content_t previous_c{};
|
||||||
|
std::vector<LoadingBlockModifierDef *> *lbm_list = nullptr;
|
||||||
|
|
||||||
for (pos.X = 0; pos.X < MAP_BLOCKSIZE; pos.X++)
|
for (pos.X = 0; pos.X < MAP_BLOCKSIZE; pos.X++)
|
||||||
for (pos.Y = 0; pos.Y < MAP_BLOCKSIZE; pos.Y++)
|
for (pos.Y = 0; pos.Y < MAP_BLOCKSIZE; pos.Y++)
|
||||||
for (pos.Z = 0; pos.Z < MAP_BLOCKSIZE; pos.Z++)
|
for (pos.Z = 0; pos.Z < MAP_BLOCKSIZE; pos.Z++) {
|
||||||
{
|
|
||||||
n = block->getNodeNoEx(pos);
|
n = block->getNodeNoEx(pos);
|
||||||
c = n.getContent();
|
c = n.getContent();
|
||||||
for (LBMManager::lbm_lookup_map::const_iterator iit = it;
|
|
||||||
iit != m_lbm_lookup.end(); ++iit) {
|
// If content_t are not matching perform an LBM lookup
|
||||||
const std::vector<LoadingBlockModifierDef *> *lbm_list =
|
if (previous_c != c) {
|
||||||
iit->second.lookup(c);
|
lbm_list = (std::vector<LoadingBlockModifierDef *> *)
|
||||||
|
it->second.lookup(c);
|
||||||
|
previous_c = c;
|
||||||
|
}
|
||||||
|
|
||||||
if (!lbm_list)
|
if (!lbm_list)
|
||||||
continue;
|
continue;
|
||||||
for (std::vector<LoadingBlockModifierDef *>::const_iterator iit =
|
for (std::vector<LoadingBlockModifierDef *>::const_iterator iit =
|
||||||
|
|
Loading…
Reference in New Issue