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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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.