mirror of
https://github.com/minetest/minetest.git
synced 2025-07-06 01:40:21 +02:00
Reserve vectors before pushing and other code quality changes (#11161)
This commit is contained in:
@ -336,22 +336,22 @@ void Hud::drawLuaElements(const v3s16 &camera_offset)
|
||||
irr::gui::IGUIFont* font = g_fontengine->getFont();
|
||||
|
||||
// Reorder elements by z_index
|
||||
std::vector<size_t> ids;
|
||||
std::vector<HudElement*> elems;
|
||||
elems.reserve(player->maxHudId());
|
||||
|
||||
for (size_t i = 0; i != player->maxHudId(); i++) {
|
||||
HudElement *e = player->getHud(i);
|
||||
if (!e)
|
||||
continue;
|
||||
|
||||
auto it = ids.begin();
|
||||
while (it != ids.end() && player->getHud(*it)->z_index <= e->z_index)
|
||||
auto it = elems.begin();
|
||||
while (it != elems.end() && (*it)->z_index <= e->z_index)
|
||||
++it;
|
||||
|
||||
ids.insert(it, i);
|
||||
elems.insert(it, e);
|
||||
}
|
||||
|
||||
for (size_t i : ids) {
|
||||
HudElement *e = player->getHud(i);
|
||||
for (HudElement *e : elems) {
|
||||
|
||||
v2s32 pos(floor(e->pos.X * (float) m_screensize.X + 0.5),
|
||||
floor(e->pos.Y * (float) m_screensize.Y + 0.5));
|
||||
@ -522,8 +522,8 @@ void Hud::drawLuaElements(const v3s16 &camera_offset)
|
||||
client->getMinimap()->drawMinimap(rect);
|
||||
break; }
|
||||
default:
|
||||
infostream << "Hud::drawLuaElements: ignoring drawform " << e->type <<
|
||||
" of hud element ID " << i << " due to unrecognized type" << std::endl;
|
||||
infostream << "Hud::drawLuaElements: ignoring drawform " << e->type
|
||||
<< " due to unrecognized type" << std::endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user