Prefixed ++/-- operators for non-primitive types

Pre-increment/decrement can be more efficient than post-increment/decrement. Post-increment/decrement usually involves keeping a copy of the previous value around and adds a little extra code.
This commit is contained in:
Zane U. Ji 2014-03-19 20:21:14 +08:00
parent 74fdc53347
commit b1a808633b
11 changed files with 39 additions and 39 deletions

View File

@ -75,7 +75,7 @@ string CaseHandler::lowerCase ( string &s )
for (
it = localString.begin();
it != localString.end();
it++ )
++it )
{
if ( *it < 0 )
continue;

View File

@ -158,7 +158,7 @@ void HouseStyle::collectRules ( const std::string& fileName,
xrr->getExcludeVector ( localExcludeVector );
for ( excludeIterator = localExcludeVector.begin();
excludeIterator != localExcludeVector.end();
excludeIterator++ )
++excludeIterator )
excludeSet.insert ( *excludeIterator );
* ( ruleCount ) += xrr->getRuleCount();
@ -169,7 +169,7 @@ void HouseStyle::collectRules ( const std::string& fileName,
std::vector<std::string>::iterator includeIterator;
for ( includeIterator = includeVector.begin();
includeIterator != includeVector.end();
includeIterator++ )
++includeIterator )
{
if ( !excludeSet.count ( *includeIterator ) )
collectRules ( *includeIterator, ruleVector, excludeSet, ruleCount );
@ -243,7 +243,7 @@ bool HouseStyle::createReport()
for ( matchIterator = contextVector.begin();
matchIterator != contextVector.end();
matchIterator++ )
++matchIterator )
{
matchIterator->report = "Not in dictionary";
matchIterator->elementCount = elementCount;
@ -269,7 +269,7 @@ bool HouseStyle::createReport()
for ( matchIterator = contextVector.begin();
matchIterator != contextVector.end();
matchIterator++ )
++matchIterator )
{
if ( rule->getAdjustCaseAttribute() )
CaseHandler::adjustCase (

View File

@ -102,7 +102,7 @@ void InsertPanel::update (
lastDoc = doc;
const std::set<wxString> &entitySet = doc->getEntitySet();
std::set<wxString>::const_iterator it;
for ( it = entitySet.begin(); it != entitySet.end(); it++ )
for ( it = entitySet.begin(); it != entitySet.end(); ++it )
list->Append ( *it );
list->Show ( true );
#if wxCHECK_VERSION(2,9,0)
@ -139,7 +139,7 @@ void InsertPanel::update (
return;
}
std::set<wxString>::const_iterator it;
for ( it = elementSet.begin(); it != elementSet.end(); it++ )
for ( it = elementSet.begin(); it != elementSet.end(); ++it )
list->Append ( *it );
list->Show ( true );
#if wxCHECK_VERSION(2,9,0)

View File

@ -118,7 +118,7 @@ void LocationPanel::indentStructure ( wxString& structure )
int count = 0;
bool justSeenContent = false;
for ( ; *s; s++, count++)
for ( ; *s; ++s, count++)
{
if (*s == '(')
{

View File

@ -181,7 +181,7 @@ MyPropertySheet::MyPropertySheet (
int index;
std::set<const wxLanguageInfo *>::const_iterator t = translations.begin();
for ( ; t != translations.end(); t++ )
for ( ; t != translations.end(); ++t )
{
index = languageBox->Append ( wxGetTranslation ( ( **t ).Description ),
( void* )( **t ).Language );

View File

@ -379,7 +379,7 @@ StyleDialog::StyleDialog (
StyleDialog::~StyleDialog()
{
std::set<wxString>::iterator it;
for ( it = tempFiles.begin(); it != tempFiles.end(); it++ )
for ( it = tempFiles.begin(); it != tempFiles.end(); ++it )
wxRemoveFile ( *it );
}
@ -484,7 +484,7 @@ void StyleDialog::OnReport ( wxCommandEvent& event )
std::string prelogUtf8, matchUtf8, postlogUtf8, replaceUtf8, reportUtf8;
wxString matchNo, prelog, match, postlog, replace, report;
int i = 0;
for ( it = matchVector.begin(); it != matchVector.end(); it++ )
for ( it = matchVector.begin(); it != matchVector.end(); ++it )
{
matchNo.Printf ( _T ( "%i" ), i + 1 ); // display numbers from 1
prelogUtf8 = flatWhiteSpace ( ( *it ).prelog );
@ -643,7 +643,7 @@ void StyleDialog::OnStyleWebReport ( wxCommandEvent& event )
ofs << "<td><b>Suggestion</b></td><td><b>Report</b></td></tr>";
std::vector<ContextMatch>::iterator it;
int matchCount = 0;
for ( it = v.begin(); it != v.end(); it++ )
for ( it = v.begin(); it != v.end(); ++it )
{
ofs << "<tr><td align=\"right\">";
ofs << ++matchCount;
@ -681,7 +681,7 @@ void StyleDialog::OnStyleWebSummary ( wxCommandEvent& event )
for (
vectorIterator = v.begin();
vectorIterator != v.end();
vectorIterator++ )
++vectorIterator )
{
if ( ( matchMap.find ( vectorIterator->match ) ) != matchMap.end() )
++ ( matchMap[vectorIterator->match] );
@ -712,7 +712,7 @@ void StyleDialog::OnStyleWebSummary ( wxCommandEvent& event )
for (
mapIterator = matchMap.begin();
mapIterator != matchMap.end();
mapIterator++ )
++mapIterator )
{
ofs << "<tr><td>";
ofs << we.xmliseTextNode ( mapIterator->first );
@ -966,7 +966,7 @@ std::string StyleDialog::flatWhiteSpace ( std::string& s )
std::string::iterator it;
std::string output;
output.reserve ( s.size() );
for ( it = s.begin(); it != s.end(); it++ )
for ( it = s.begin(); it != s.end(); ++it )
{
if ( *it == '\t' || *it == '\r' || *it == '\n' )
output += ' ';

View File

@ -48,7 +48,7 @@ void ThreadReaper::add ( wxThread *thread )
for ( itr = mList.begin(); itr != mList.end(); )
{
if ( (**itr).IsAlive() )
itr++;
++itr;
else
itr = mList.erase ( itr );
}
@ -65,7 +65,7 @@ void ThreadReaper::clear()
// It's safe to call wxThread::Wait() now
std::vector<boost::shared_ptr<wxThread> >::iterator itr;
for ( itr = threads.begin(); itr != threads.end(); itr++)
for ( itr = threads.begin(); itr != threads.end(); ++itr)
{
// This will cause the whole program to abort in linux with early
// versions of wxWidgets. A easy way to fix this is to rethrow

View File

@ -49,7 +49,7 @@ XmlAssociateXsd::XmlAssociateXsd (
std::vector<std::pair<std::string, std::string> > attributeVector;
attributeVector = parser->getAttributeVector();
std::vector<std::pair<std::string, std::string> >::iterator it;
for ( it = attributeVector.begin(); it != attributeVector.end(); it++ )
for ( it = attributeVector.begin(); it != attributeVector.end(); ++it )
{
if ( it->first == "targetNamespace" )
{
@ -119,7 +119,7 @@ void XMLCALL XmlAssociateXsd::start ( void *data,
{
d->buffer += " xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"";
std::map<std::string, std::string>::iterator it;
for ( it = d->namespaceMap.begin(); it != d->namespaceMap.end(); it++ )
for ( it = d->namespaceMap.begin(); it != d->namespaceMap.end(); ++it )
{
d->buffer += " ";
d->buffer += it->first;

View File

@ -1068,7 +1068,7 @@ MyFrame::~MyFrame()
ThreadReaper::get().clear();
std::vector<wxString>::iterator it;
for ( it = tempFileVector.begin(); it != tempFileVector.end(); it++ )
for ( it = tempFileVector.begin(); it != tempFileVector.end(); ++it )
wxRemoveFile ( *it );
layout = manager.SavePerspective();

View File

@ -490,7 +490,7 @@ void XmlCtrl::handleOpenAngleBracket ( wxKeyEvent& event )
wxString choice;
std::set<wxString> &childSet = elementMap[parent];
std::set<wxString>::iterator it;
for ( it = childSet.begin(); it != childSet.end(); it++ )
for ( it = childSet.begin(); it != childSet.end(); ++it )
{
if ( !choice.empty() )
choice.append ( _T ( "<" ) );
@ -591,7 +591,7 @@ void XmlCtrl::handleEquals ( wxKeyEvent& event )
int cutoff = BUFSIZ;
for ( valueSetIterator = valueSet.begin();
valueSetIterator != valueSet.end();
valueSetIterator++ )
++valueSetIterator )
{
if ( ! ( cutoff-- ) )
break;
@ -657,7 +657,7 @@ void XmlCtrl::handleSpace ( wxKeyEvent& event )
wxString tag = GetTextRange ( tagStartPos, pos );
std::map<wxString, std::set<wxString> > &curAttMap = attributeMap[elementName];
std::map<wxString, std::set<wxString> >::iterator it;
for ( it = curAttMap.begin(); it != curAttMap.end(); it++ )
for ( it = curAttMap.begin(); it != curAttMap.end(); ++it )
{
// avoid duplicate attributes
if ( tag.Contains ( it->first + _T ( "=" ) ) )
@ -700,7 +700,7 @@ void XmlCtrl::handleAmpersand ( wxKeyEvent& event )
std::set<wxString>::iterator it = entitySet.begin();
choice += *it;
choice += _T ( ";" );
for ( it++; it != entitySet.end(); it++ )
for ( it++; it != entitySet.end(); ++it )
{
choice += _T ( "<" );
choice += *it;
@ -1786,7 +1786,7 @@ wxString XmlCtrl::getOpenTag ( const wxString& element )
requiredAttributeSet = requiredAttributeMap[element];
if ( !requiredAttributeSet.empty() )
{
for ( it = requiredAttributeSet.begin(); it != requiredAttributeSet.end(); it++ )
for ( it = requiredAttributeSet.begin(); it != requiredAttributeSet.end(); ++it )
{
openTag += _T ( " " );
openTag += *it;

View File

@ -142,7 +142,7 @@ void XmlSchemaGenerator::generateData ( const wxString &elementName,
std::map<wxString, ChildData>::iterator itr;
std::set<wxString> previous;
elmtItr = data.nodes.begin();
for ( ; elmtItr != data.nodes.end(); elmtItr++ )
for ( ; elmtItr != data.nodes.end(); ++elmtItr )
{
previous.clear();
@ -157,14 +157,14 @@ void XmlSchemaGenerator::generateData ( const wxString &elementName,
countMap[name] += 1;
}
std::map<wxString, size_t>::iterator countItr = countMap.begin();
for ( ; countItr != countMap.end(); countItr++ )
for ( ; countItr != countMap.end(); ++countItr )
{
if ( childMap[countItr->first].maxOccurs < countItr->second )
childMap[countItr->first].maxOccurs = countItr->second;
}
if ( childMap.size() == countMap.size() )
continue;
for ( itr = childMap.begin(); itr != childMap.end(); itr++ )
for ( itr = childMap.begin(); itr != childMap.end(); ++itr )
{
if ( countMap.find ( itr->first ) != countMap.end() )
continue;
@ -176,7 +176,7 @@ void XmlSchemaGenerator::generateData ( const wxString &elementName,
std::set<wxString> &optAttrs = data.optAttrs;
std::map<wxString, const XMLCh *>::iterator attrItr;
elmtItr = data.nodes.begin();
for ( ; elmtItr != data.nodes.end(); elmtItr++ )
for ( ; elmtItr != data.nodes.end(); ++elmtItr )
{
if ( ! ( **elmtItr ).hasAttributes() )
continue;
@ -201,7 +201,7 @@ void XmlSchemaGenerator::generateData ( const wxString &elementName,
}
if ( attrMap.size() == optAttrs.size() )
continue;
for ( attrItr = attrMap.begin(); attrItr != attrMap.end(); attrItr++ )
for ( attrItr = attrMap.begin(); attrItr != attrMap.end(); ++attrItr )
{
if ( attrs->getNamedItem ( ( const XMLCh * )
WrapXerces::toString ( attrItr->first ).GetData() ) == NULL )
@ -275,7 +275,7 @@ void XmlSchemaGenerator::generateSchema ( ElmtData &data, size_t nIndent )
size_t minOccurs = 1, maxOccurs = 1, minTotal = 0;
std::map<wxString, ChildData>::const_iterator itr;
for ( itr = data.children.begin(); itr != data.children.end(); itr++ )
for ( itr = data.children.begin(); itr != data.children.end(); ++itr )
{
if ( itr->second.minOccurs < minOccurs )
minOccurs = itr->second.minOccurs;
@ -298,7 +298,7 @@ void XmlSchemaGenerator::generateSchema ( ElmtData &data, size_t nIndent )
std::vector<wxString>::const_iterator seqItr;
seqItr = data.sequence.begin();
for ( ; seqItr != data.sequence.end(); seqItr++ )
for ( ; seqItr != data.sequence.end(); ++seqItr )
{
const ChildData &child = data.children[*seqItr];
addIndent ( schema, nIndent );
@ -345,7 +345,7 @@ void XmlSchemaGenerator::generateSchema ( ElmtData &data, size_t nIndent )
}
std::map<wxString, const XMLCh *>::const_iterator attrItr;
attrItr = data.attrMap.begin();
for ( ; attrItr != data.attrMap.end(); attrItr++ )
for ( ; attrItr != data.attrMap.end(); ++attrItr )
{
addIndent ( schema, nIndent );
schema << _T("<xs:attribute name=\"") << attrItr->first
@ -388,7 +388,7 @@ void XmlSchemaGenerator::generateDTD ( ElmtData &data, size_t WXUNUSED ( nIndent
seqItr = data.sequence.begin();
if (data.useSequence)
{
for ( ; seqItr != data.sequence.end(); seqItr++ )
for ( ; seqItr != data.sequence.end(); ++seqItr )
{
schema << separator << *seqItr;
separator = _T(", ");
@ -403,7 +403,7 @@ void XmlSchemaGenerator::generateDTD ( ElmtData &data, size_t WXUNUSED ( nIndent
else
{
size_t minTotal = 0;
for ( ; seqItr != data.sequence.end(); seqItr++ )
for ( ; seqItr != data.sequence.end(); ++seqItr )
{
schema << separator << *seqItr;
separator = _T(" | ");
@ -422,7 +422,7 @@ void XmlSchemaGenerator::generateDTD ( ElmtData &data, size_t WXUNUSED ( nIndent
std::map<wxString, const XMLCh *>::const_iterator attrItr;
attrItr = data.attrMap.begin();
for ( ; attrItr != data.attrMap.end(); attrItr++ )
for ( ; attrItr != data.attrMap.end(); ++attrItr )
{
schema << indent << attrItr->first << _T(" CDATA");
if ( attrItr->second != NULL ) // Has default value
@ -452,7 +452,7 @@ bool XmlSchemaGenerator::getSequence ( std::vector<wxString> &sequence,
do
{
retry = false;
for ( itr = elmtMap.begin(); itr != elmtMap.end(); itr++ )
for ( itr = elmtMap.begin(); itr != elmtMap.end(); ++itr )
{
seqFindItr = std::find ( sequence.begin(), sequence.end(),
itr->first );
@ -462,7 +462,7 @@ bool XmlSchemaGenerator::getSequence ( std::vector<wxString> &sequence,
seqItr = sequence.begin();
prevItr = itr->second.prevSiblings.begin();
prevEnd = itr->second.prevSiblings.end();
for ( ; prevItr != prevEnd; prevItr++ )
for ( ; prevItr != prevEnd; ++prevItr )
{ // Find last index of dependent elements
seqFindItr = std::find ( sequence.begin(), sequence.end(),
*prevItr );
@ -491,7 +491,7 @@ bool XmlSchemaGenerator::getSequence ( std::vector<wxString> &sequence,
if ( seqItr != sequence.end() )
{
seqItr++;
++seqItr;
}
sequence.insert ( seqItr, itr->first );
wxLogDebug ( _T(" %s"), itr->first.c_str() );