mail[Wesnoth-commits] r43378 - /trunk/src/ai/composite/goal.cpp


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

Header


Content

Posted by guillaume . melquiond on June 12, 2010 - 20:58:
Author: silene
Date: Sat Jun 12 20:58:56 2010
New Revision: 43378

URL: http://svn.gna.org/viewcvs/wesnoth?rev=43378&view=rev
Log:
Removed redundant attribute lookup.

Modified:
    trunk/src/ai/composite/goal.cpp

Modified: trunk/src/ai/composite/goal.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/ai/composite/goal.cpp?rev=43378&r1=43377&r2=43378&view=diff
==============================================================================
--- trunk/src/ai/composite/goal.cpp (original)
+++ trunk/src/ai/composite/goal.cpp Sat Jun 12 20:58:56 2010
@@ -95,9 +95,9 @@
 void target_unit_goal::on_create()
 {
        goal::on_create();
-       if (cfg_.has_attribute("value")) {
+       if (const config::attribute_value *v = cfg_.get("value")) {
                try {
-                       value_ = boost::lexical_cast<double>(cfg_["value"]);
+                       value_ = boost::lexical_cast<double>(*v);
                } catch (boost::bad_lexical_cast){
                        ERR_AI_GOAL << "bad value of goal"<<std::endl;
                        value_ = 0;
@@ -136,17 +136,17 @@
 void protect_goal::on_create()
 {
        goal::on_create();
-       if (cfg_.has_attribute("value")) {
+       if (const config::attribute_value *v = cfg_.get("value")) {
                try {
-                       value_ = boost::lexical_cast<double>(cfg_["value"]);
+                       value_ = boost::lexical_cast<double>(*v);
                } catch (boost::bad_lexical_cast){
                        ERR_AI_GOAL << "bad value of protect_goal"<<std::endl;
                        value_ = 0;
                }
        }
-       if (cfg_.has_attribute("protect_radius")) {
+       if (const config::attribute_value *v = cfg_.get("protect_radius")) {
                try {
-                       radius_ = 
boost::lexical_cast<int>(cfg_["protect_radius"]);
+                       radius_ = boost::lexical_cast<int>(*v);
                } catch (boost::bad_lexical_cast){
                        ERR_AI_GOAL << "bad protection radius of 
protect_goal"<<std::endl;
                        radius_ = 1;




Related Messages


Powered by MHonArc, Updated Sat Jun 12 21:00:13 2010