mail[Wesnoth-commits] r43359 - /trunk/src/random.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:57:
Author: silene
Date: Sat Jun 12 20:57:36 2010
New Revision: 43359

URL: http://svn.gna.org/viewcvs/wesnoth?rev=43359&view=rev
Log:
Avoided costly roundtrip through strings.

Modified:
    trunk/src/random.cpp

Modified: trunk/src/random.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/random.cpp?rev=43359&r1=43358&r2=43359&view=diff
==============================================================================
--- trunk/src/random.cpp (original)
+++ trunk/src/random.cpp Sat Jun 12 20:57:36 2010
@@ -168,12 +168,12 @@
        if (random_child_ >= random_size) {
                random_child_ = random_size + 1;
                int res = generator_.get_next_random() & 0x7FFFFFFF;
-               (random_->add_child("random"))["value"] = 
lexical_cast<std::string>(res);
+               (random_->add_child("random"))["value"] = res;
                LOG_RND << "get_random() returning " << res << " (added to 
random_)\n";
                return res;
        } else {
                int mine = generator_.get_next_random();
-               int stored = 
lexical_cast_default<int>(random_->child("random", random_child_++)["value"]);
+               int stored = random_->child("random", 
random_child_++)["value"];
                if (mine != stored) {
                        if (check) {
                                ERR_RND << "Random number mismatch, mine " << 
mine << " vs " << stored << "\n";
@@ -247,7 +247,7 @@
         * @todo  older savegames don't have random_seed stored, evaluate 
later
      * whether default can be removed again. Look after branching 1.5.
         */
-    random_seed_(lexical_cast_default<int>(cfg["random_seed"], 42)),
+    random_seed_(cfg["random_seed"].to_int(42)),
     random_pool_(random_seed_),
     random_calls_(0)
 {




Related Messages


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