Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

xrRender, xrCDB: use reserve to optimize inserts into containers #1341

Merged
merged 3 commits into from
Jul 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/Include/xrRender/ObjectSpaceRender.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ class IObjectSpaceRender

virtual void dbgRender() = 0;
virtual void dbgAddSphere(const Fsphere& sphere, u32 colour) = 0;
virtual void dbgReserveSphere(size_t count) = 0;
virtual void SetShader() = 0;
};
#endif // DEBUG
Expand Down
1 change: 1 addition & 0 deletions src/Layers/xrRender/DetailManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,7 @@ void CDetailManager::Load()
dtFS->r_chunk_safe(0, &dtH, sizeof(dtH));
R_ASSERT(dtH.version() == DETAIL_VERSION);
u32 m_count = dtH.object_count();
objects.reserve(m_count);

// Models
IReader* m_fs = dtFS->open_chunk(1);
Expand Down
8 changes: 3 additions & 5 deletions src/Layers/xrRender/ResourceManager_Loader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -149,12 +149,10 @@ void CResourceManager::StoreNecessaryTextures()
if (!m_necessary.empty())
return;

auto it = m_textures.begin();
auto it_e = m_textures.end();

for (; it != it_e; ++it)
m_necessary.reserve(m_textures.size());
for (auto& mtex : m_textures)
{
LPCSTR texture_name = it->first;
LPCSTR texture_name = mtex.first;
if (strstr(texture_name, DELIMITER "levels" DELIMITER))
continue;
if (!strchr(texture_name, _DELIMITER))
Expand Down
1 change: 1 addition & 0 deletions src/Layers/xrRender/dxObjectSpaceRender.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ dxObjectSpaceRender::dxObjectSpaceRender() { m_shDebug.create("debug" DELIMITER
dxObjectSpaceRender::~dxObjectSpaceRender() { m_shDebug.destroy(); }
void dxObjectSpaceRender::Copy(IObjectSpaceRender& _in) { *this = *(dxObjectSpaceRender*)&_in; }
void dxObjectSpaceRender::dbgAddSphere(const Fsphere& sphere, u32 colour) { dbg_S.emplace_back(sphere, colour); }
void dxObjectSpaceRender::dbgReserveSphere(size_t count) { dbg_S.reserve(count); }
void dxObjectSpaceRender::dbgRender()
{
R_ASSERT(bDebug);
Expand Down
1 change: 1 addition & 0 deletions src/Layers/xrRender/dxObjectSpaceRender.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ class dxObjectSpaceRender : public IObjectSpaceRender

virtual void dbgRender();
virtual void dbgAddSphere(const Fsphere& sphere, u32 colour);
virtual void dbgReserveSphere(size_t count);
virtual void SetShader();

private:
Expand Down
6 changes: 5 additions & 1 deletion src/xrCDB/xr_area_raypick.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,11 @@ bool CObjectSpace::_RayPick(
STYPE_COLLIDEABLE | ((tgt & rqtObstacle) ? STYPE_OBSTACLE : 0) | ((tgt & rqtShape) ? STYPE_SHAPE : 0);
g_SpatialSpace->q_ray(r_spatial, 0, d_flags, start, dir, range);
// Determine visibility for dynamic part of scene
for (auto spatial : r_spatial)
#ifdef DEBUG
if (bDebug())
(*m_pRender)->dbgReserveSphere(r_spatial.size());
#endif
for (auto* spatial : r_spatial)
{
IGameObject* collidable = spatial->dcast_GameObject();
if (0 == collidable)
Expand Down
Loading