Skip to content

Commit

Permalink
#5584: Use std::unordered_map to have faster lookups, the CamRenderer…
Browse files Browse the repository at this point in the history
…::addRenderable method is no longer contributing in the profiler.
  • Loading branch information
codereader committed Nov 1, 2021
1 parent 1eee48d commit a9e77a3
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions libs/render/CamRenderer.h
Expand Up @@ -6,7 +6,7 @@

#include "VectorLightList.h"

#include <map>
#include <unordered_map>

namespace render
{
Expand Down Expand Up @@ -62,7 +62,7 @@ class CamRenderer :
// Renderables added with addLitObject() need to be stored until their
// light lists can be calculated, which can't happen until all the lights
// are submitted too.
std::map<Shader*, LitRenderables> _litRenderables;
std::unordered_map<Shader*, LitRenderables> _litRenderables;

// Intersect all received renderables wiith lights
void calculateLightIntersections()
Expand Down Expand Up @@ -231,9 +231,7 @@ class CamRenderer :
LitRenderables emptyList;
emptyList.reserve(1024);

auto result = _litRenderables.insert(
std::make_pair(&shader, std::move(emptyList))
);
auto result = _litRenderables.emplace(&shader, std::move(emptyList));
wxASSERT(result.second);
iter = result.first;
}
Expand All @@ -242,7 +240,7 @@ class CamRenderer :

// Store a LitRenderable object for this renderable
LitRenderable lr { renderable, litObject, localToWorld, entity };
iter->second.push_back(std::move(lr));
iter->second.emplace_back(std::move(lr));
}
};

Expand Down

0 comments on commit a9e77a3

Please sign in to comment.