Author: silene
Date: Sun Sep 12 18:13:42 2010
New Revision: 46409
URL: http://svn.gna.org/viewcvs/wesnoth?rev=46409&view=rev
Log:
Avoided costly roundtrip through strings.
Modified:
trunk/src/unit_types.cpp
Modified: trunk/src/unit_types.cpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/unit_types.cpp?rev=46409&r1=46408&r2=46409&view=diff
==============================================================================
--- trunk/src/unit_types.cpp (original)
+++ trunk/src/unit_types.cpp Sun Sep 12 18:13:42 2010
@@ -335,9 +335,8 @@
if (const config &resistance = cfg_.child("resistance"))
{
- const std::string &val = resistance[attack.type()];
- if (!val.empty()) {
- res = atoi(val.c_str());
+ if (const::config::attribute_value *val =
resistance.get(attack.type())) {
+ res = *val;
result_found = true;
}
}
@@ -435,9 +434,8 @@
}
const std::string& id =
map.get_terrain_info(underlying.front()).id();
- const std::string &val = movement_costs[id];
- if (!val.empty()) {
- res = atoi(val.c_str());
+ if (const config::attribute_value *val =
movement_costs.get(id)) {
+ res = *val;
result_found = true;
}
}
@@ -517,10 +515,8 @@
}
const std::string& id =
map.get_terrain_info(underlying.front()).id();
- const std::string &val = defense[id];
-
- if (!val.empty()) {
- res = atoi(val.c_str());
+ if (const config::attribute_value *val = defense.get(id)) {
+ res = *val;
result_found = true;
}
}
_______________________________________________
Wesnoth-commits mailing list
[email protected]
https://mail.gna.org/listinfo/wesnoth-commits