VirtualBox

Changeset 36561 in vbox for trunk/src/VBox/Runtime/common


Ignore:
Timestamp:
Apr 5, 2011 1:42:59 PM (14 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
70996
Message:

RTCString::join: Optimization.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Runtime/common/string/ministring.cpp

    r36544 r36561  
    368368    if (a_rList.size() > 1)
    369369    {
     370        /* calc the required size */
     371        size_t cbNeeded = a_rstrSep.length() * (a_rList.size() - 1) + 1;
     372        for (size_t i = 0; i < a_rList.size(); ++i)
     373            cbNeeded += a_rList.at(i).length();
     374        strRet.reserve(cbNeeded);
     375
     376        /* do the appending. */
    370377        for (size_t i = 0; i < a_rList.size() - 1; ++i)
    371             strRet += a_rList.at(i) + a_rstrSep;
    372     }
    373     if (a_rList.size() > 0)
    374         strRet += a_rList.last();
     378        {
     379            strRet.append(a_rList.at(i));
     380            strRet.append(a_rstrSep);
     381        }
     382        strRet.append(a_rList.last());
     383    }
     384    /* special case: one list item. */
     385    else if (a_rList.size() > 0)
     386        strRet.append(a_rList.last());
    375387
    376388    return strRet;
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