From b1a808633b049980a785054614c963c5c5c39944 Mon Sep 17 00:00:00 2001 From: "Zane U. Ji" Date: Wed, 19 Mar 2014 20:21:14 +0800 Subject: [PATCH] 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. --- src/casehandler.cpp | 2 +- src/housestyle.cpp | 8 ++++---- src/insertpanel.cpp | 4 ++-- src/locationpanel.cpp | 2 +- src/mypropertysheet.cpp | 2 +- src/styledialog.cpp | 12 ++++++------ src/threadreaper.cpp | 4 ++-- src/xmlassociatexsd.cpp | 4 ++-- src/xmlcopyeditor.cpp | 2 +- src/xmlctrl.cpp | 10 +++++----- src/xmlschemagenerator.cpp | 28 ++++++++++++++-------------- 11 files changed, 39 insertions(+), 39 deletions(-) diff --git a/src/casehandler.cpp b/src/casehandler.cpp index 3d29d8d..eec7bf6 100644 --- a/src/casehandler.cpp +++ b/src/casehandler.cpp @@ -75,7 +75,7 @@ string CaseHandler::lowerCase ( string &s ) for ( it = localString.begin(); it != localString.end(); - it++ ) + ++it ) { if ( *it < 0 ) continue; diff --git a/src/housestyle.cpp b/src/housestyle.cpp index 09e6c79..de9a7f7 100644 --- a/src/housestyle.cpp +++ b/src/housestyle.cpp @@ -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::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 ( diff --git a/src/insertpanel.cpp b/src/insertpanel.cpp index a3aff7f..04a40c2 100644 --- a/src/insertpanel.cpp +++ b/src/insertpanel.cpp @@ -102,7 +102,7 @@ void InsertPanel::update ( lastDoc = doc; const std::set &entitySet = doc->getEntitySet(); std::set::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::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) diff --git a/src/locationpanel.cpp b/src/locationpanel.cpp index 2c783e7..e7e0983 100644 --- a/src/locationpanel.cpp +++ b/src/locationpanel.cpp @@ -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 == '(') { diff --git a/src/mypropertysheet.cpp b/src/mypropertysheet.cpp index 265291b..25f3ee9 100644 --- a/src/mypropertysheet.cpp +++ b/src/mypropertysheet.cpp @@ -181,7 +181,7 @@ MyPropertySheet::MyPropertySheet ( int index; std::set::const_iterator t = translations.begin(); - for ( ; t != translations.end(); t++ ) + for ( ; t != translations.end(); ++t ) { index = languageBox->Append ( wxGetTranslation ( ( **t ).Description ), ( void* )( **t ).Language ); diff --git a/src/styledialog.cpp b/src/styledialog.cpp index e1c64d5..0e6cc60 100644 --- a/src/styledialog.cpp +++ b/src/styledialog.cpp @@ -379,7 +379,7 @@ StyleDialog::StyleDialog ( StyleDialog::~StyleDialog() { std::set::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 << "SuggestionReport"; std::vector::iterator it; int matchCount = 0; - for ( it = v.begin(); it != v.end(); it++ ) + for ( it = v.begin(); it != v.end(); ++it ) { ofs << ""; 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 << ""; 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 += ' '; diff --git a/src/threadreaper.cpp b/src/threadreaper.cpp index 1b91b15..5bec1d0 100644 --- a/src/threadreaper.cpp +++ b/src/threadreaper.cpp @@ -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 >::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 diff --git a/src/xmlassociatexsd.cpp b/src/xmlassociatexsd.cpp index 782d419..0ed1977 100644 --- a/src/xmlassociatexsd.cpp +++ b/src/xmlassociatexsd.cpp @@ -49,7 +49,7 @@ XmlAssociateXsd::XmlAssociateXsd ( std::vector > attributeVector; attributeVector = parser->getAttributeVector(); std::vector >::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::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; diff --git a/src/xmlcopyeditor.cpp b/src/xmlcopyeditor.cpp index 6cad272..8053ca2 100644 --- a/src/xmlcopyeditor.cpp +++ b/src/xmlcopyeditor.cpp @@ -1068,7 +1068,7 @@ MyFrame::~MyFrame() ThreadReaper::get().clear(); std::vector::iterator it; - for ( it = tempFileVector.begin(); it != tempFileVector.end(); it++ ) + for ( it = tempFileVector.begin(); it != tempFileVector.end(); ++it ) wxRemoveFile ( *it ); layout = manager.SavePerspective(); diff --git a/src/xmlctrl.cpp b/src/xmlctrl.cpp index 276ec47..3cd437d 100644 --- a/src/xmlctrl.cpp +++ b/src/xmlctrl.cpp @@ -490,7 +490,7 @@ void XmlCtrl::handleOpenAngleBracket ( wxKeyEvent& event ) wxString choice; std::set &childSet = elementMap[parent]; std::set::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 > &curAttMap = attributeMap[elementName]; std::map >::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::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; diff --git a/src/xmlschemagenerator.cpp b/src/xmlschemagenerator.cpp index a090821..7740e7b 100644 --- a/src/xmlschemagenerator.cpp +++ b/src/xmlschemagenerator.cpp @@ -142,7 +142,7 @@ void XmlSchemaGenerator::generateData ( const wxString &elementName, std::map::iterator itr; std::set 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::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 &optAttrs = data.optAttrs; std::map::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::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::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::const_iterator attrItr; attrItr = data.attrMap.begin(); - for ( ; attrItr != data.attrMap.end(); attrItr++ ) + for ( ; attrItr != data.attrMap.end(); ++attrItr ) { addIndent ( schema, nIndent ); schema << _T("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::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 &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 &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 &sequence, if ( seqItr != sequence.end() ) { - seqItr++; + ++seqItr; } sequence.insert ( seqItr, itr->first ); wxLogDebug ( _T(" %s"), itr->first.c_str() );