VirtualBox

Changeset 18148 in vbox for trunk/include/VBox/com/string.h


Ignore:
Timestamp:
Mar 23, 2009 4:10:48 PM (16 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
44847
Message:

Main: don't call length() twice

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/VBox/com/string.h

    r17973 r18148  
    476476            return false;
    477477
    478         if (length() < that.length())
     478        size_t l1 = length();
     479        size_t l2 = that.length();
     480        if (l1 < l2)
    479481            return false;
    480482
    481         size_t l = length() - that.length();
     483        size_t l = l1 - l2;
    482484        if (cs == CaseSensitive)
    483485            return ::RTStrCmp(&str[l], that.str) == 0;
     
    491493            return false;
    492494
    493         if (length() < that.length())
     495        size_t l1 = length();
     496        size_t l2 = that.length();
     497        if (l1 < l2)
    494498            return false;
    495499
    496500        if (cs == CaseSensitive)
    497             return ::RTStrNCmp(str, that.str, that.length()) == 0;
     501            return ::RTStrNCmp(str, that.str, l2) == 0;
    498502        else
    499             return ::RTStrNICmp(str, that.str, that.length()) == 0;
     503            return ::RTStrNICmp(str, that.str, l2) == 0;
    500504    }
    501505
Note: See TracChangeset for help on using the changeset viewer.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette