Skip to content
Snippets Groups Projects
Commit e81bcef1 authored by Per Hedbor's avatar Per Hedbor
Browse files

Minimize overhead in the (sadly needed) body of the loop.

If the body of the loop is removed, the foreach() is optimized away.
Also, the assignment of the global counter is removed as well in the
versions that use a global variable, which is really a bug.
parent 939bf668
Branches
Tags
No related merge requests found
...@@ -9,10 +9,8 @@ int n; ...@@ -9,10 +9,8 @@ int n;
void perform() void perform()
{ {
int res; int res;
foreach( const, int i ) foreach( const, int i )
res ++; res=1;
n=sizeof(const); n=sizeof(const);
} }
......
...@@ -9,10 +9,8 @@ int n; ...@@ -9,10 +9,8 @@ int n;
void perform() void perform()
{ {
int res; int res;
foreach( const;int ind; int i ) foreach( const;int ind; int i )
res ++; res=1;
n=sizeof(const); n=sizeof(const);
} }
......
...@@ -10,7 +10,7 @@ void perform() ...@@ -10,7 +10,7 @@ void perform()
{ {
int res; int res;
foreach( const;;n ) foreach( const;;n )
res ++; res=1;
n++; n++;
} }
......
...@@ -10,7 +10,7 @@ void perform() ...@@ -10,7 +10,7 @@ void perform()
{ {
int res; int res;
foreach( const;int ind;n ) foreach( const;int ind;n )
res ++; res=1;
n++; n++;
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment