Author: alink
Date: Sat May 9 04:52:56 2009
New Revision: 35494
URL: http://svn.gna.org/viewcvs/wesnoth?rev=35494&view=rev
Log:
Simple optimization about accessing unit_type, speed-up AI recruiting.
Impact linearly depend to the number of unit types, so help a lot when few eras
are installed.
Also help a little big-keep scenario like in NR.
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=35494&r1=35493&r2=35494&view=diff
==============================================================================
--- trunk/src/unit_types.cpp (original)
+++ trunk/src/unit_types.cpp Sat May 9 04:52:56 2009
@@ -1291,26 +1291,29 @@
DBG_UT << "Building unit type " << ut->first << ", level " << status <<
"\n";
- const config& unit_cfg = find_config(key);
-
switch (status){
- case unit_type::CREATED:
+ case unit_type::CREATED: {
+ const config& unit_cfg = find_config(key);
ut->second.set_config(unit_cfg);
ut->second.build_created(unit_cfg, movement_types_,
races_, unit_cfg_->child_range("trait"));
break;
- case unit_type::HELP_INDEX:
+ }
+ case unit_type::HELP_INDEX: {
//build the stuff that is needed to feed the help index
- if ( (ut->second.build_status() == unit_type::NOT_BUILT) ||
(ut->second.build_status() == unit_type::CREATED) )
+ if ( (ut->second.build_status() == unit_type::NOT_BUILT) ||
(ut->second.build_status() == unit_type::CREATED) ) {
+ const config& unit_cfg = find_config(key);
ut->second.build_help_index(unit_cfg,
movement_types_, races_, unit_cfg_->child_range("trait"));
-
- add_advancefrom(unit_cfg);
+ add_advancefrom(unit_cfg);
+ }
break;
+ }
case unit_type::WITHOUT_ANIMATIONS:
- case unit_type::FULL:
+ case unit_type::FULL: {
if ( (ut->second.build_status() == unit_type::NOT_BUILT) ||
(ut->second.build_status() == unit_type::CREATED) ||
(ut->second.build_status() == unit_type::HELP_INDEX) )
{
+ const config& unit_cfg = find_config(key);
ut->second.build_full(unit_cfg,
movement_types_, races_, unit_cfg_->child_range("trait"));
if ( (ut->second.build_status() == unit_type::NOT_BUILT) ||
@@ -1318,6 +1321,7 @@
add_advancefrom(unit_cfg);
}
break;
+ }
default:
break;
}
_______________________________________________
Wesnoth-commits mailing list
[email protected]
https://mail.gna.org/listinfo/wesnoth-commits