Author: ai0867
Date: Tue Jan 12 02:48:58 2010
New Revision: 40675

URL: http://svn.gna.org/viewcvs/wesnoth?rev=40675&view=rev
Log:
Rather than copy-constructing your vector, use a const reference to the original

Modified:
    branches/fendrin_pathfind/src/astarsearch.cpp

Modified: branches/fendrin_pathfind/src/astarsearch.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/branches/fendrin_pathfind/src/astarsearch.cpp?rev=40675&r1=40674&r2=40675&view=diff
==============================================================================
--- branches/fendrin_pathfind/src/astarsearch.cpp (original)
+++ branches/fendrin_pathfind/src/astarsearch.cpp Tue Jan 12 02:48:58 2010
@@ -85,23 +85,23 @@
                if (!teleports->empty()) {
 
                        double new_srch = 1.0;
-                       std::vector<std::set<map_location> > sources = 
teleports->get_sources();
-
-                       std::vector<std::set<map_location> >::iterator it = 
sources.begin();
+                       const std::vector<std::set<map_location> > &sources = 
teleports->get_sources();
+
+                       std::vector<std::set<map_location> >::const_iterator it 
= sources.begin();
                        for(; it != sources.end(); ++it) {
-                               for(std::set<map_location>::iterator it2 = 
it->begin(); it2 != it->end(); it2++) {
+                               for(std::set<map_location>::const_iterator it2 
= it->begin(); it2 != it->end(); it2++) {
                                        const double tmp_srch = heuristic(c, 
*it2);
                                        if (tmp_srch < new_srch) { new_srch = 
tmp_srch; }
                                }
                        }
 
                        double new_dsth = 1.0;
-                       std::vector<std::set<map_location> > destinations = 
teleports->get_destinations();
+                       const std::vector<std::set<map_location> > 
&destinations = teleports->get_destinations();
 
                        it = destinations.begin();
 
                        for(; it != destinations.end(); ++it) {
-                               std::set<map_location>::iterator it2;
+                               std::set<map_location>::const_iterator it2;
                                for(it2 = it->begin(); it2 != it->end(); ++it2) 
{
                                        const double tmp_dsth = heuristic(*it2, 
dst);
                                        if (tmp_dsth < new_dsth) { new_dsth = 
tmp_dsth; }


_______________________________________________
Wesnoth-commits mailing list
[email protected]
https://mail.gna.org/listinfo/wesnoth-commits

Reply via email to