mail[Wesnoth-commits] r44446 - in /trunk/src: tod_manager.cpp tod_manager.hpp


Others Months | Index by Date | Thread Index
>>   [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Header


Content

Posted by alinktomine on July 20, 2010 - 21:46:
Author: alink
Date: Tue Jul 20 21:46:04 2010
New Revision: 44446

URL: http://svn.gna.org/viewcvs/wesnoth?rev=44446&view=rev
Log:
Optimize local ToD access by using reference

Modified:
    trunk/src/tod_manager.cpp
    trunk/src/tod_manager.hpp

Modified: trunk/src/tod_manager.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/tod_manager.cpp?rev=44446&r1=44445&r2=44446&view=diff
==============================================================================
--- trunk/src/tod_manager.cpp (original)
+++ trunk/src/tod_manager.cpp Tue Jul 20 21:46:04 2010
@@ -119,22 +119,19 @@
        return get_time_of_day_turn(turn_ - 1);
 }
 
-time_of_day tod_manager::get_time_of_day(const map_location& loc, int 
n_turn) const
-{
-       time_of_day res = get_time_of_day_turn(n_turn ? n_turn : turn_);
-
+const time_of_day& tod_manager::get_time_of_day(const map_location& loc, int 
n_turn) const
+{
        if (loc.valid()) {
                for (std::vector<area_time_of_day>::const_reverse_iterator
                     i = areas_.rbegin(), i_end = areas_.rend(); i != i_end; 
++i)
                {
                        if (i->hexes.count(loc) != 1) continue;
                        VALIDATE(i->times.size(), _("No time of day has been 
defined."));
-                       res = i->times[(n_turn - 1) % i->times.size()];
-                       break;
-               }
-       }
-
-       return res;
+                       return i->times[(n_turn - 1) % i->times.size()];
+               }
+       }
+
+       return get_time_of_day_turn(n_turn ? n_turn : turn_);
 }
 
 bool tod_manager::is_start_ToD(const std::string& random_start_time)

Modified: trunk/src/tod_manager.hpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/tod_manager.hpp?rev=44446&r1=44445&r2=44446&view=diff
==============================================================================
--- trunk/src/tod_manager.hpp (original)
+++ trunk/src/tod_manager.hpp Tue Jul 20 21:46:04 2010
@@ -43,7 +43,7 @@
                 * Returns time of day object in the turn at a location.
                 * If nturn = 0 use current turn
                 */
-               time_of_day get_time_of_day(const map_location& loc, int 
n_turn = 0) const;
+               const time_of_day& get_time_of_day(const map_location& loc, 
int n_turn = 0) const;
                /**
                 * Sets global time of day in this turn.
                 */




Related Messages


Powered by MHonArc, Updated Tue Jul 20 22:00:12 2010