mail[Wesnoth-commits] r20297 - /branches/1.2/src/serialization/string_utils.cpp


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

Header


Content

Posted by Soliton on September 11, 2007 - 08:04:
Author: soliton
Date: Tue Sep 11 08:04:09 2007
New Revision: 20297

URL: http://svn.gna.org/viewcvs/wesnoth?rev=20297&view=rev
Log:
merge r20293: tighten the loop in wildcard_string_match, eliminate a string 
copy operation

Modified:
    branches/1.2/src/serialization/string_utils.cpp

Modified: branches/1.2/src/serialization/string_utils.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/branches/1.2/src/serialization/string_utils.cpp?rev=20297&r1=20296&r2=20297&view=diff
==============================================================================
--- branches/1.2/src/serialization/string_utils.cpp (original)
+++ branches/1.2/src/serialization/string_utils.cpp Tue Sep 11 08:04:09 2007
@@ -688,24 +688,19 @@
        do {
                matches = true;
                //now try to place the str into the solid space
-               std::string test_str = str.substr(current);
-               for(std::string::size_type i=0; i < solid_len; ++i) {
-                       if(i > test_str.length()) {
+               const std::string::size_type test_len = str.length() - 
current;
+               for(std::string::size_type i=0; i < solid_len && matches; 
++i) {
+                       char solid_c = match[solid_begin + i];
+                       if(i > test_len || !(solid_c == '?' || solid_c == 
str[current+i])) {
                                matches = false;
-                               break;
-                       }
-                       char solid_c = match[solid_begin + i];
-                       if(solid_c != '?' && solid_c != test_str[i]) {
-                               matches = false;
-                               break;
                        }
                }
                if(matches) {
                        //the solid space matched, now consume it and attempt 
to find more
-                       std::string consumed_match = (solid_begin+solid_len < 
match.length())
+                       const std::string consumed_match = 
(solid_begin+solid_len < match.length())
                                ? match.substr(solid_end) : "";
-                       std::string consumed_str = (solid_len < 
test_str.length())
-                               ? test_str.substr(solid_len) : "";
+                       const std::string consumed_str = (solid_len < 
test_len)
+                               ? str.substr(current+solid_len) : "";
                        matches = wildcard_string_match(consumed_str, 
consumed_match);
                }
        } while(wild_matching && !matches && ++current < str.length());




Related Messages


Powered by MHonArc, Updated Tue Sep 11 10:00:34 2007