Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Dec 5, 2015, 7:10:56 PM (9 years ago)
Author:
muemart
Message:

Use emplace_back instead of push_back if beneficial

Location:
code/branches/cpp11_v2/src/libraries/tools
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • code/branches/cpp11_v2/src/libraries/tools/DebugDrawer.cc

    r10916 r10918  
    433433    int DebugDrawer::addLineVertex(const Ogre::Vector3& vertex, const Ogre::ColourValue& colour)
    434434    {
    435         lineVertices.push_back(VertexPair(vertex, colour));
     435        lineVertices.emplace_back(vertex, colour);
    436436        return linesIndex++;
    437437    }
     
    445445    int DebugDrawer::addTriangleVertex(const Ogre::Vector3& vertex, const Ogre::ColourValue& colour)
    446446    {
    447         triangleVertices.push_back(VertexPair(vertex, colour));
     447        triangleVertices.emplace_back(vertex, colour);
    448448        return trianglesIndex++;
    449449    }
  • code/branches/cpp11_v2/src/libraries/tools/DynamicLines.cc

    r5781 r10918  
    6969    void DynamicLines::addPoint(Real x, Real y, Real z)
    7070    {
    71         mPoints.push_back(Vector3(x,y,z));
     71        mPoints.emplace_back(x,y,z);
    7272        mDirty = true;
    7373    }
  • code/branches/cpp11_v2/src/libraries/tools/IcoSphere.cc

    r10916 r10918  
    126126                removeLineIndices(f.v3, f.v1);
    127127
    128                 faces2.push_back(TriangleIndices(f.v1, a, c));
    129                 faces2.push_back(TriangleIndices(f.v2, b, a));
    130                 faces2.push_back(TriangleIndices(f.v3, c, b));
    131                 faces2.push_back(TriangleIndices(a, b, c));
     128                faces2.emplace_back(f.v1, a, c);
     129                faces2.emplace_back(f.v2, b, a);
     130                faces2.emplace_back(f.v3, c, b);
     131                faces2.emplace_back(a, b, c);
    132132
    133133                addTriangleLines(f.v1, a, c);
     
    142142    void IcoSphere::addLineIndices(int index0, int index1)
    143143    {
    144         lineIndices.push_back(LineIndices(index0, index1));
     144        lineIndices.emplace_back(index0, index1);
    145145    }
    146146
     
    163163    {
    164164        Ogre::Real length = vertex.length();
    165         vertices.push_back(Ogre::Vector3(vertex.x / length, vertex.y / length, vertex.z / length));
     165        vertices.emplace_back(vertex.x / length, vertex.y / length, vertex.z / length);
    166166        return index++;
    167167    }
     
    188188    void IcoSphere::addFace(int index0, int index1, int index2)
    189189    {
    190         faces.push_back(TriangleIndices(index0, index1, index2));
     190        faces.emplace_back(index0, index1, index2);
    191191    }
    192192
     
    217217
    218218        for (const Ogre::Vector3& vertex : vertices)
    219             target->push_back(VertexPair(transform * vertex, colour));
     219            target->emplace_back(transform * vertex, colour);
    220220
    221221        return vertices.size();
Note: See TracChangeset for help on using the changeset viewer.