Replace post-increment on iterators with pre-increment

This is a micro-optimization, as pre-increment is at least as efficient
as post-increment and typically slightly more so because it doesn't need
to make a copy of the iterator, and better conforms to the prevailing
C++ style.

Closes https://github.com/wxWidgets/wxWidgets/pull/655
This commit is contained in:
orbitcowboy
2017-12-27 14:00:44 +01:00
committed by Vadim Zeitlin
parent f83d16aa46
commit f423b88ded
6 changed files with 9 additions and 9 deletions

View File

@@ -2734,7 +2734,7 @@ unsigned int wxDataViewTreeStore::GetChildren( const wxDataViewItem &item, wxDat
if (!node) return 0;
wxDataViewTreeStoreNodeList::iterator iter;
for (iter = node->GetChildren().begin(); iter != node->GetChildren().end(); iter++)
for (iter = node->GetChildren().begin(); iter != node->GetChildren().end(); ++iter)
{
wxDataViewTreeStoreNode* child = *iter;
children.Add( child->GetItem() );
@@ -2939,7 +2939,7 @@ void wxDataViewTreeCtrl::DeleteChildren( const wxDataViewItem& item )
wxDataViewItemArray array;
wxDataViewTreeStoreNodeList::iterator iter;
for (iter = node->GetChildren().begin(); iter != node->GetChildren().end(); iter++)
for (iter = node->GetChildren().begin(); iter != node->GetChildren().end(); ++iter)
{
wxDataViewTreeStoreNode* child = *iter;
array.Add( child->GetItem() );

View File

@@ -982,7 +982,7 @@ wxMenuItem *wxMenuBarBase::FindItem(int itemid, wxMenu **menu) const
wxMenuItem *item = NULL;
size_t count = GetMenuCount(), i;
wxMenuList::const_iterator it;
for ( i = 0, it = m_menus.begin(); !item && (i < count); i++, it++ )
for ( i = 0, it = m_menus.begin(); !item && (i < count); i++, ++it )
{
item = (*it)->FindItem(itemid, menu);
}

View File

@@ -903,7 +903,7 @@ wxTarNumber wxTarInputStream::GetHeaderNumber(int id) const
wxTarNumber n = 0;
wxString::const_iterator p = value.begin();
while (p != value.end() && *p == ' ')
p++;
++p;
while (isdigit(*p))
n = n * 10 + (*p++ - '0');
return n;

View File

@@ -3654,7 +3654,7 @@ public:
if( node->GetItem() == *m_iter )
{
m_iter++;
++m_iter;
return DoJob::CONTINUE;
}
else

View File

@@ -327,7 +327,7 @@ void wxNotificationMessageWindow::AddVisibleNotification(wxNotificationMessageWi
{
bool found = false;
for ( wxVector<wxNotificationMessageWindow*>::iterator it = ms_visibleNotifications.begin();
it != ms_visibleNotifications.end(); it++ )
it != ms_visibleNotifications.end(); ++it )
{
if ( *it == notif )
{
@@ -345,7 +345,7 @@ void wxNotificationMessageWindow::AddVisibleNotification(wxNotificationMessageWi
void wxNotificationMessageWindow::RemoveVisibleNotification(wxNotificationMessageWindow* notif)
{
for ( wxVector<wxNotificationMessageWindow*>::iterator it = ms_visibleNotifications.begin();
it != ms_visibleNotifications.end(); it++ )
it != ms_visibleNotifications.end(); ++it )
{
if ( *it == notif )
{

View File

@@ -1195,7 +1195,7 @@ void wxMenuBar::RebuildAccelTable()
size_t nAccelCount = 0;
size_t i, count = GetMenuCount();
wxMenuList::iterator it;
for ( i = 0, it = m_menus.begin(); i < count; i++, it++ )
for ( i = 0, it = m_menus.begin(); i < count; i++, ++it )
{
nAccelCount += (*it)->GetAccelCount();
}
@@ -1205,7 +1205,7 @@ void wxMenuBar::RebuildAccelTable()
wxAcceleratorEntry *accelEntries = new wxAcceleratorEntry[nAccelCount];
nAccelCount = 0;
for ( i = 0, it = m_menus.begin(); i < count; i++, it++ )
for ( i = 0, it = m_menus.begin(); i < count; i++, ++it )
{
nAccelCount += (*it)->CopyAccels(&accelEntries[nAccelCount]);
}