qbsp: fix stupid perf bug in BuildSurfaces that I introduced

(unnecessary insertions and redundant lookups to a map)
This commit is contained in:
Eric Wasylishen 2016-11-01 12:48:46 -06:00
parent 2094114a18
commit a96aa4de70
2 changed files with 9 additions and 16 deletions

View File

@ -377,26 +377,19 @@ visible face.
==================
*/
surface_t *
BuildSurfaces(std::map<int, face_t *> &planefaces)
BuildSurfaces(const std::map<int, face_t *> &planefaces)
{
int i;
surface_t *surf, *surfaces;
face_t *face;
surfaces = NULL;
for (i = 0; i < map.numplanes(); i++) {
if (planefaces[i] == nullptr)
continue;
surface_t *surfaces = NULL;
for (const auto &entry : planefaces) {
/* create a new surface to hold the faces on this plane */
surf = (surface_t *)AllocMem(SURFACE, 1, true);
surf->planenum = i;
surface_t *surf = (surface_t *)AllocMem(SURFACE, 1, true);
surf->planenum = entry.first;
surf->next = surfaces;
surfaces = surf;
surf->faces = planefaces[i];
for (face = surf->faces; face; face = face->next)
surf->faces = entry.second;
for (const face_t *face = surf->faces; face; face = face->next)
csgmergefaces++;
/* Calculate bounding box and flags */
CalcSurfaceInfo(surf);
}

View File

@ -368,7 +368,7 @@ int PlaneInvEqual(const plane_t *p1, const plane_t *p2);
extern int csgmergefaces;
// build surfaces is also used by GatherNodeFaces
surface_t *BuildSurfaces(std::map<int, face_t *> &planefaces);
surface_t *BuildSurfaces(const std::map<int, face_t *> &planefaces);
face_t *NewFaceFromFace(face_t *in);
void SplitFace(face_t *in, const plane_t *split, face_t **front, face_t **back);
void UpdateFaceSphere(face_t *in);