]> git.tdb.fi Git - libs/gl.git/blobdiff - source/animation/armature.cpp
Use emplace_back when a new object is being constructed
[libs/gl.git] / source / animation / armature.cpp
index 6e921e3f8e9ea95246b8dae655ba54f701d0689d..acfffbf7b3cc2a53b9c1afb419842aac2b8e84c7 100644 (file)
@@ -8,31 +8,31 @@ namespace GL {
 
 Armature::Link &Armature::add_link()
 {
-       links.push_back(Link(string(), links.size()));
+       links.emplace_back(string(), links.size());
        return links.back();
 }
 
 const Armature::Link &Armature::get_link(unsigned index) const
 {
-       for(vector<Link>::const_iterator i=links.begin(); i!=links.end(); ++i)
-               if(i->get_index()==index)
-                       return *i;
-       throw key_error(typeid(list<Link>));
+       for(const Link &l: links)
+               if(l.get_index()==index)
+                       return l;
+       throw key_error(index);
 }
 
 const Armature::Link &Armature::get_link(const string &name) const
 {
-       for(vector<Link>::const_iterator i=links.begin(); i!=links.end(); ++i)
-               if(i->get_name()==name)
-                       return *i;
-       throw key_error(typeid(list<Link>));
+       for(const Link &l: links)
+               if(l.get_name()==name)
+                       return l;
+       throw key_error(name);
 }
 
 unsigned Armature::get_max_link_index() const
 {
        unsigned max_index = 0;
-       for(vector<Link>::const_iterator i=links.begin(); i!=links.end(); ++i)
-               max_index = max(max_index, i->get_index());
+       for(const Link &l: links)
+               max_index = max(max_index, l.get_index());
        return max_index;
 }