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 ( for (
it = localString.begin(); it = localString.begin();
it != localString.end(); it != localString.end();
it++ ) ++it )
{ {
if ( *it < 0 ) if ( *it < 0 )
continue; continue;

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -48,7 +48,7 @@ void ThreadReaper::add ( wxThread *thread )
for ( itr = mList.begin(); itr != mList.end(); ) for ( itr = mList.begin(); itr != mList.end(); )
{ {
if ( (**itr).IsAlive() ) if ( (**itr).IsAlive() )
itr++; ++itr;
else else
itr = mList.erase ( itr ); itr = mList.erase ( itr );
} }
@ -65,7 +65,7 @@ void ThreadReaper::clear()
// It's safe to call wxThread::Wait() now // It's safe to call wxThread::Wait() now
std::vector<boost::shared_ptr<wxThread> >::iterator itr; 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 // This will cause the whole program to abort in linux with early
// versions of wxWidgets. A easy way to fix this is to rethrow // 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; std::vector<std::pair<std::string, std::string> > attributeVector;
attributeVector = parser->getAttributeVector(); attributeVector = parser->getAttributeVector();
std::vector<std::pair<std::string, std::string> >::iterator it; 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" ) 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\""; d->buffer += " xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"";
std::map<std::string, std::string>::iterator it; 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 += " ";
d->buffer += it->first; d->buffer += it->first;

View File

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

View File

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

View File

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