EDN Admin
Well-known member
Below is the same question asked on stackoverflow
http://stackoverflow.com/questions/795987/c-iterators-loop-optimization http://stackoverflow.com/questions/795987/c-iterators-loop-optimization
<span class="x_Apple-style-span" style="font-family:Arial,Liberation Sans,DejaVu Sans,sans-serif; font-size:14px; border-collapse:collapse
<pre class="lang-c prettyprint" style="margin-bottom:10px; padding-bottom:5px; border-right-width:0px; border-bottom-width:0px; border-left-width:0px; border-style:initial; border-color:initial; font-size:14px; vertical-align:baseline; background-color:#eeeeee; font-family:Consolas,Menlo,Monaco,Lucida Console,Liberation Mono,DejaVu Sans Mono,Bitstream Vera Sans Mono,Courier New,monospace,serif; overflow-x:auto; overflow-y:auto; width:auto; max-height:600px <code style="margin-bottom:0px; padding-bottom:0px; border-right-width:0px; border-bottom-width:0px; border-left-width:0px; border-style:initial; border-color:initial; font-size:14px; vertical-align:baseline; background-color:#eeeeee; font-family:Consolas,Menlo,Monaco,Lucida Console,Liberation Mono,DejaVu Sans Mono,Bitstream Vera Sans Mono,Courier New,monospace,serif <span class="kwd" style="margin-bottom:0px; padding-bottom:0px; border-right-width:0px; border-bottom-width:0px; border-left-width:0px; border-style:initial; border-color:initial; font-size:14px; vertical-align:baseline; background-color:transparent; color:#00008b for<span class="pun" style="margin-bottom:0px; padding-bottom:0px; border-right-width:0px; border-bottom-width:0px; border-left-width:0px; border-style:initial; border-color:initial; font-size:14px; vertical-align:baseline; background-color:transparent; color:#000000 (<span class="pln" style="margin-bottom:0px; padding-bottom:0px; border-right-width:0px; border-bottom-width:0px; border-left-width:0px; border-style:initial; border-color:initial; font-size:14px; vertical-align:baseline; background-color:transparent; color:#000000 const_iterator it <span class="pun" style="margin-bottom:0px; padding-bottom:0px; border-right-width:0px; border-bottom-width:0px; border-left-width:0px; border-style:initial; border-color:initial; font-size:14px; vertical-align:baseline; background-color:transparent; color:#000000 =<span class="pln" style="margin-bottom:0px; padding-bottom:0px; border-right-width:0px; border-bottom-width:0px; border-left-width:0px; border-style:initial; border-color:initial; font-size:14px; vertical-align:baseline; background-color:transparent; color:#000000 list<span class="pun" style="margin-bottom:0px; padding-bottom:0px; border-right-width:0px; border-bottom-width:0px; border-left-width:0px; border-style:initial; border-color:initial; font-size:14px; vertical-align:baseline; background-color:transparent; color:#000000 .<span class="pln" style="margin-bottom:0px; padding-bottom:0px; border-right-width:0px; border-bottom-width:0px; border-left-width:0px; border-style:initial; border-color:initial; font-size:14px; vertical-align:baseline; background-color:transparent; color:#000000 begin<span class="pun" style="margin-bottom:0px; padding-bottom:0px; border-right-width:0px; border-bottom-width:0px; border-left-width:0px; border-style:initial; border-color:initial; font-size:14px; vertical-align:baseline; background-color:transparent; color:#000000 (),<span class="pln" style="margin-bottom:0px; padding-bottom:0px; border-right-width:0px; border-bottom-width:0px; border-left-width:0px; border-style:initial; border-color:initial; font-size:14px; vertical-align:baseline; background-color:transparent; color:#000000 <br/> const_iterator ite <span class="pun" style="margin-bottom:0px; padding-bottom:0px; border-right-width:0px; border-bottom-width:0px; border-left-width:0px; border-style:initial; border-color:initial; font-size:14px; vertical-align:baseline; background-color:transparent; color:#000000 =<span class="pln" style="margin-bottom:0px; padding-bottom:0px; border-right-width:0px; border-bottom-width:0px; border-left-width:0px; border-style:initial; border-color:initial; font-size:14px; vertical-align:baseline; background-color:transparent; color:#000000 list<span class="pun" style="margin-bottom:0px; padding-bottom:0px; border-right-width:0px; border-bottom-width:0px; border-left-width:0px; border-style:initial; border-color:initial; font-size:14px; vertical-align:baseline; background-color:transparent; color:#000000 .<span class="pln" style="margin-bottom:0px; padding-bottom:0px; border-right-width:0px; border-bottom-width:0px; border-left-width:0px; border-style:initial; border-color:initial; font-size:14px; vertical-align:baseline; background-color:transparent; color:#000000 end<span class="pun" style="margin-bottom:0px; padding-bottom:0px; border-right-width:0px; border-bottom-width:0px; border-left-width:0px; border-style:initial; border-color:initial; font-size:14px; vertical-align:baseline; background-color:transparent; color:#000000 ();<span class="pln" style="margin-bottom:0px; padding-bottom:0px; border-right-width:0px; border-bottom-width:0px; border-left-width:0px; border-style:initial; border-color:initial; font-size:14px; vertical-align:baseline; background-color:transparent; color:#000000 <br/> it <span class="pun" style="margin-bottom:0px; padding-bottom:0px; border-right-width:0px; border-bottom-width:0px; border-left-width:0px; border-style:initial; border-color:initial; font-size:14px; vertical-align:baseline; background-color:transparent; color:#000000 !=<span class="pln" style="margin-bottom:0px; padding-bottom:0px; border-right-width:0px; border-bottom-width:0px; border-left-width:0px; border-style:initial; border-color:initial; font-size:14px; vertical-align:baseline; background-color:transparent; color:#000000 ite<span class="pun" style="margin-bottom:0px; padding-bottom:0px; border-right-width:0px; border-bottom-width:0px; border-left-width:0px; border-style:initial; border-color:initial; font-size:14px; vertical-align:baseline; background-color:transparent; color:#000000 ;<span class="pln" style="margin-bottom:0px; padding-bottom:0px; border-right-width:0px; border-bottom-width:0px; border-left-width:0px; border-style:initial; border-color:initial; font-size:14px; vertical-align:baseline; background-color:transparent; color:#000000 <span class="pun" style="margin-bottom:0px; padding-bottom:0px; border-right-width:0px; border-bottom-width:0px; border-left-width:0px; border-style:initial; border-color:initial; font-size:14px; vertical-align:baseline; background-color:transparent; color:#000000 ++<span class="pln" style="margin-bottom:0px; padding-bottom:0px; border-right-width:0px; border-bottom-width:0px; border-left-width:0px; border-style:initial; border-color:initial; font-size:14px; vertical-align:baseline; background-color:transparent; color:#000000 it<span class="pun" style="margin-bottom:0px; padding-bottom:0px; border-right-width:0px; border-bottom-width:0px; border-left-width:0px; border-style:initial; border-color:initial; font-size:14px; vertical-align:baseline; background-color:transparent; color:#000000 )<span class="pln" style="margin-bottom:0px; padding-bottom:0px; border-right-width:0px; border-bottom-width:0px; border-left-width:0px; border-style:initial; border-color:initial; font-size:14px; vertical-align:baseline; background-color:transparent; color:#000000 <br/>[/code][/code]
<pre class="lang-c prettyprint" style="margin-bottom:10px; padding-bottom:5px; border-right-width:0px; border-bottom-width:0px; border-left-width:0px; border-style:initial; border-color:initial; font-size:14px; vertical-align:baseline; background-color:#eeeeee; font-family:Consolas,Menlo,Monaco,Lucida Console,Liberation Mono,DejaVu Sans Mono,Bitstream Vera Sans Mono,Courier New,monospace,serif; overflow-x:auto; overflow-y:auto; width:auto; max-height:600px <code style="margin-bottom:0px; padding-bottom:0px; border-right-width:0px; border-bottom-width:0px; border-left-width:0px; border-style:initial; border-color:initial; font-size:14px; vertical-align:baseline; background-color:#eeeeee; font-family:Consolas,Menlo,Monaco,Lucida Console,Liberation Mono,DejaVu Sans Mono,Bitstream Vera Sans Mono,Courier New,monospace,serif <span class="kwd" style="margin-bottom:0px; padding-bottom:0px; border-right-width:0px; border-bottom-width:0px; border-left-width:0px; border-style:initial; border-color:initial; font-size:14px; vertical-align:baseline; background-color:transparent; color:#00008b for<span class="pun" style="margin-bottom:0px; padding-bottom:0px; border-right-width:0px; border-bottom-width:0px; border-left-width:0px; border-style:initial; border-color:initial; font-size:14px; vertical-align:baseline; background-color:transparent; color:#000000 (<span class="pln" style="margin-bottom:0px; padding-bottom:0px; border-right-width:0px; border-bottom-width:0px; border-left-width:0px; border-style:initial; border-color:initial; font-size:14px; vertical-align:baseline; background-color:transparent; color:#000000 const_iterator it <span class="pun" style="margin-bottom:0px; padding-bottom:0px; border-right-width:0px; border-bottom-width:0px; border-left-width:0px; border-style:initial; border-color:initial; font-size:14px; vertical-align:baseline; background-color:transparent; color:#000000 =<span class="pln" style="margin-bottom:0px; padding-bottom:0px; border-right-width:0px; border-bottom-width:0px; border-left-width:0px; border-style:initial; border-color:initial; font-size:14px; vertical-align:baseline; background-color:transparent; color:#000000 list<span class="pun" style="margin-bottom:0px; padding-bottom:0px; border-right-width:0px; border-bottom-width:0px; border-left-width:0px; border-style:initial; border-color:initial; font-size:14px; vertical-align:baseline; background-color:transparent; color:#000000 .<span class="pln" style="margin-bottom:0px; padding-bottom:0px; border-right-width:0px; border-bottom-width:0px; border-left-width:0px; border-style:initial; border-color:initial; font-size:14px; vertical-align:baseline; background-color:transparent; color:#000000 begin<span class="pun" style="margin-bottom:0px; padding-bottom:0px; border-right-width:0px; border-bottom-width:0px; border-left-width:0px; border-style:initial; border-color:initial; font-size:14px; vertical-align:baseline; background-color:transparent; color:#000000 ();<span class="pln" style="margin-bottom:0px; padding-bottom:0px; border-right-width:0px; border-bottom-width:0px; border-left-width:0px; border-style:initial; border-color:initial; font-size:14px; vertical-align:baseline; background-color:transparent; color:#000000 <br/> it <span class="pun" style="margin-bottom:0px; padding-bottom:0px; border-right-width:0px; border-bottom-width:0px; border-left-width:0px; border-style:initial; border-color:initial; font-size:14px; vertical-align:baseline; background-color:transparent; color:#000000 !=<span class="pln" style="margin-bottom:0px; padding-bottom:0px; border-right-width:0px; border-bottom-width:0px; border-left-width:0px; border-style:initial; border-color:initial; font-size:14px; vertical-align:baseline; background-color:transparent; color:#000000 list<span class="pun" style="margin-bottom:0px; padding-bottom:0px; border-right-width:0px; border-bottom-width:0px; border-left-width:0px; border-style:initial; border-color:initial; font-size:14px; vertical-align:baseline; background-color:transparent; color:#000000 .<span class="pln" style="margin-bottom:0px; padding-bottom:0px; border-right-width:0px; border-bottom-width:0px; border-left-width:0px; border-style:initial; border-color:initial; font-size:14px; vertical-align:baseline; background-color:transparent; color:#000000 end<span class="pun" style="margin-bottom:0px; padding-bottom:0px; border-right-width:0px; border-bottom-width:0px; border-left-width:0px; border-style:initial; border-color:initial; font-size:14px; vertical-align:baseline; background-color:transparent; color:#000000 ();<span class="pln" style="margin-bottom:0px; padding-bottom:0px; border-right-width:0px; border-bottom-width:0px; border-left-width:0px; border-style:initial; border-color:initial; font-size:14px; vertical-align:baseline; background-color:transparent; color:#000000 <span class="pun" style="margin-bottom:0px; padding-bottom:0px; border-right-width:0px; border-bottom-width:0px; border-left-width:0px; border-style:initial; border-color:initial; font-size:14px; vertical-align:baseline; background-color:transparent; color:#000000 ++<span class="pln" style="margin-bottom:0px; padding-bottom:0px; border-right-width:0px; border-bottom-width:0px; border-left-width:0px; border-style:initial; border-color:initial; font-size:14px; vertical-align:baseline; background-color:transparent; color:#000000 it<span class="pun" style="margin-bottom:0px; padding-bottom:0px; border-right-width:0px; border-bottom-width:0px; border-left-width:0px; border-style:initial; border-color:initial; font-size:14px; vertical-align:baseline; background-color:transparent; color:#000000 )[/code][/code]
http://stackoverflow.com/questions/795987/c-iterators-loop-optimization
What I wanna know here, is the official MS-specific answer for this question, since I only use visual studio both at work/home.<br/>
My little research was that(under VS2012): the release version will be the same for both if dont consider different register usage; there will be difference which cause the first version more efficient if I put __declspec(noinline) before vector::end().
BTW, whats the equivalent pragma/declspec for normal non-member function to not get inlined?<br/>
http://stackoverflow.com/questions/795987/c-iterators-loop-optimization
PS: I know the first would be wrong if end() actually gets changed inside loop, lets just consider the situation where end() is const through the loop. http://stackoverflow.com/questions/795987/c-iterators-loop-optimization <hr class="sig I am a passionate game programmer.
View the full article
http://stackoverflow.com/questions/795987/c-iterators-loop-optimization http://stackoverflow.com/questions/795987/c-iterators-loop-optimization
<span class="x_Apple-style-span" style="font-family:Arial,Liberation Sans,DejaVu Sans,sans-serif; font-size:14px; border-collapse:collapse
<pre class="lang-c prettyprint" style="margin-bottom:10px; padding-bottom:5px; border-right-width:0px; border-bottom-width:0px; border-left-width:0px; border-style:initial; border-color:initial; font-size:14px; vertical-align:baseline; background-color:#eeeeee; font-family:Consolas,Menlo,Monaco,Lucida Console,Liberation Mono,DejaVu Sans Mono,Bitstream Vera Sans Mono,Courier New,monospace,serif; overflow-x:auto; overflow-y:auto; width:auto; max-height:600px <code style="margin-bottom:0px; padding-bottom:0px; border-right-width:0px; border-bottom-width:0px; border-left-width:0px; border-style:initial; border-color:initial; font-size:14px; vertical-align:baseline; background-color:#eeeeee; font-family:Consolas,Menlo,Monaco,Lucida Console,Liberation Mono,DejaVu Sans Mono,Bitstream Vera Sans Mono,Courier New,monospace,serif <span class="kwd" style="margin-bottom:0px; padding-bottom:0px; border-right-width:0px; border-bottom-width:0px; border-left-width:0px; border-style:initial; border-color:initial; font-size:14px; vertical-align:baseline; background-color:transparent; color:#00008b for<span class="pun" style="margin-bottom:0px; padding-bottom:0px; border-right-width:0px; border-bottom-width:0px; border-left-width:0px; border-style:initial; border-color:initial; font-size:14px; vertical-align:baseline; background-color:transparent; color:#000000 (<span class="pln" style="margin-bottom:0px; padding-bottom:0px; border-right-width:0px; border-bottom-width:0px; border-left-width:0px; border-style:initial; border-color:initial; font-size:14px; vertical-align:baseline; background-color:transparent; color:#000000 const_iterator it <span class="pun" style="margin-bottom:0px; padding-bottom:0px; border-right-width:0px; border-bottom-width:0px; border-left-width:0px; border-style:initial; border-color:initial; font-size:14px; vertical-align:baseline; background-color:transparent; color:#000000 =<span class="pln" style="margin-bottom:0px; padding-bottom:0px; border-right-width:0px; border-bottom-width:0px; border-left-width:0px; border-style:initial; border-color:initial; font-size:14px; vertical-align:baseline; background-color:transparent; color:#000000 list<span class="pun" style="margin-bottom:0px; padding-bottom:0px; border-right-width:0px; border-bottom-width:0px; border-left-width:0px; border-style:initial; border-color:initial; font-size:14px; vertical-align:baseline; background-color:transparent; color:#000000 .<span class="pln" style="margin-bottom:0px; padding-bottom:0px; border-right-width:0px; border-bottom-width:0px; border-left-width:0px; border-style:initial; border-color:initial; font-size:14px; vertical-align:baseline; background-color:transparent; color:#000000 begin<span class="pun" style="margin-bottom:0px; padding-bottom:0px; border-right-width:0px; border-bottom-width:0px; border-left-width:0px; border-style:initial; border-color:initial; font-size:14px; vertical-align:baseline; background-color:transparent; color:#000000 (),<span class="pln" style="margin-bottom:0px; padding-bottom:0px; border-right-width:0px; border-bottom-width:0px; border-left-width:0px; border-style:initial; border-color:initial; font-size:14px; vertical-align:baseline; background-color:transparent; color:#000000 <br/> const_iterator ite <span class="pun" style="margin-bottom:0px; padding-bottom:0px; border-right-width:0px; border-bottom-width:0px; border-left-width:0px; border-style:initial; border-color:initial; font-size:14px; vertical-align:baseline; background-color:transparent; color:#000000 =<span class="pln" style="margin-bottom:0px; padding-bottom:0px; border-right-width:0px; border-bottom-width:0px; border-left-width:0px; border-style:initial; border-color:initial; font-size:14px; vertical-align:baseline; background-color:transparent; color:#000000 list<span class="pun" style="margin-bottom:0px; padding-bottom:0px; border-right-width:0px; border-bottom-width:0px; border-left-width:0px; border-style:initial; border-color:initial; font-size:14px; vertical-align:baseline; background-color:transparent; color:#000000 .<span class="pln" style="margin-bottom:0px; padding-bottom:0px; border-right-width:0px; border-bottom-width:0px; border-left-width:0px; border-style:initial; border-color:initial; font-size:14px; vertical-align:baseline; background-color:transparent; color:#000000 end<span class="pun" style="margin-bottom:0px; padding-bottom:0px; border-right-width:0px; border-bottom-width:0px; border-left-width:0px; border-style:initial; border-color:initial; font-size:14px; vertical-align:baseline; background-color:transparent; color:#000000 ();<span class="pln" style="margin-bottom:0px; padding-bottom:0px; border-right-width:0px; border-bottom-width:0px; border-left-width:0px; border-style:initial; border-color:initial; font-size:14px; vertical-align:baseline; background-color:transparent; color:#000000 <br/> it <span class="pun" style="margin-bottom:0px; padding-bottom:0px; border-right-width:0px; border-bottom-width:0px; border-left-width:0px; border-style:initial; border-color:initial; font-size:14px; vertical-align:baseline; background-color:transparent; color:#000000 !=<span class="pln" style="margin-bottom:0px; padding-bottom:0px; border-right-width:0px; border-bottom-width:0px; border-left-width:0px; border-style:initial; border-color:initial; font-size:14px; vertical-align:baseline; background-color:transparent; color:#000000 ite<span class="pun" style="margin-bottom:0px; padding-bottom:0px; border-right-width:0px; border-bottom-width:0px; border-left-width:0px; border-style:initial; border-color:initial; font-size:14px; vertical-align:baseline; background-color:transparent; color:#000000 ;<span class="pln" style="margin-bottom:0px; padding-bottom:0px; border-right-width:0px; border-bottom-width:0px; border-left-width:0px; border-style:initial; border-color:initial; font-size:14px; vertical-align:baseline; background-color:transparent; color:#000000 <span class="pun" style="margin-bottom:0px; padding-bottom:0px; border-right-width:0px; border-bottom-width:0px; border-left-width:0px; border-style:initial; border-color:initial; font-size:14px; vertical-align:baseline; background-color:transparent; color:#000000 ++<span class="pln" style="margin-bottom:0px; padding-bottom:0px; border-right-width:0px; border-bottom-width:0px; border-left-width:0px; border-style:initial; border-color:initial; font-size:14px; vertical-align:baseline; background-color:transparent; color:#000000 it<span class="pun" style="margin-bottom:0px; padding-bottom:0px; border-right-width:0px; border-bottom-width:0px; border-left-width:0px; border-style:initial; border-color:initial; font-size:14px; vertical-align:baseline; background-color:transparent; color:#000000 )<span class="pln" style="margin-bottom:0px; padding-bottom:0px; border-right-width:0px; border-bottom-width:0px; border-left-width:0px; border-style:initial; border-color:initial; font-size:14px; vertical-align:baseline; background-color:transparent; color:#000000 <br/>[/code][/code]
<pre class="lang-c prettyprint" style="margin-bottom:10px; padding-bottom:5px; border-right-width:0px; border-bottom-width:0px; border-left-width:0px; border-style:initial; border-color:initial; font-size:14px; vertical-align:baseline; background-color:#eeeeee; font-family:Consolas,Menlo,Monaco,Lucida Console,Liberation Mono,DejaVu Sans Mono,Bitstream Vera Sans Mono,Courier New,monospace,serif; overflow-x:auto; overflow-y:auto; width:auto; max-height:600px <code style="margin-bottom:0px; padding-bottom:0px; border-right-width:0px; border-bottom-width:0px; border-left-width:0px; border-style:initial; border-color:initial; font-size:14px; vertical-align:baseline; background-color:#eeeeee; font-family:Consolas,Menlo,Monaco,Lucida Console,Liberation Mono,DejaVu Sans Mono,Bitstream Vera Sans Mono,Courier New,monospace,serif <span class="kwd" style="margin-bottom:0px; padding-bottom:0px; border-right-width:0px; border-bottom-width:0px; border-left-width:0px; border-style:initial; border-color:initial; font-size:14px; vertical-align:baseline; background-color:transparent; color:#00008b for<span class="pun" style="margin-bottom:0px; padding-bottom:0px; border-right-width:0px; border-bottom-width:0px; border-left-width:0px; border-style:initial; border-color:initial; font-size:14px; vertical-align:baseline; background-color:transparent; color:#000000 (<span class="pln" style="margin-bottom:0px; padding-bottom:0px; border-right-width:0px; border-bottom-width:0px; border-left-width:0px; border-style:initial; border-color:initial; font-size:14px; vertical-align:baseline; background-color:transparent; color:#000000 const_iterator it <span class="pun" style="margin-bottom:0px; padding-bottom:0px; border-right-width:0px; border-bottom-width:0px; border-left-width:0px; border-style:initial; border-color:initial; font-size:14px; vertical-align:baseline; background-color:transparent; color:#000000 =<span class="pln" style="margin-bottom:0px; padding-bottom:0px; border-right-width:0px; border-bottom-width:0px; border-left-width:0px; border-style:initial; border-color:initial; font-size:14px; vertical-align:baseline; background-color:transparent; color:#000000 list<span class="pun" style="margin-bottom:0px; padding-bottom:0px; border-right-width:0px; border-bottom-width:0px; border-left-width:0px; border-style:initial; border-color:initial; font-size:14px; vertical-align:baseline; background-color:transparent; color:#000000 .<span class="pln" style="margin-bottom:0px; padding-bottom:0px; border-right-width:0px; border-bottom-width:0px; border-left-width:0px; border-style:initial; border-color:initial; font-size:14px; vertical-align:baseline; background-color:transparent; color:#000000 begin<span class="pun" style="margin-bottom:0px; padding-bottom:0px; border-right-width:0px; border-bottom-width:0px; border-left-width:0px; border-style:initial; border-color:initial; font-size:14px; vertical-align:baseline; background-color:transparent; color:#000000 ();<span class="pln" style="margin-bottom:0px; padding-bottom:0px; border-right-width:0px; border-bottom-width:0px; border-left-width:0px; border-style:initial; border-color:initial; font-size:14px; vertical-align:baseline; background-color:transparent; color:#000000 <br/> it <span class="pun" style="margin-bottom:0px; padding-bottom:0px; border-right-width:0px; border-bottom-width:0px; border-left-width:0px; border-style:initial; border-color:initial; font-size:14px; vertical-align:baseline; background-color:transparent; color:#000000 !=<span class="pln" style="margin-bottom:0px; padding-bottom:0px; border-right-width:0px; border-bottom-width:0px; border-left-width:0px; border-style:initial; border-color:initial; font-size:14px; vertical-align:baseline; background-color:transparent; color:#000000 list<span class="pun" style="margin-bottom:0px; padding-bottom:0px; border-right-width:0px; border-bottom-width:0px; border-left-width:0px; border-style:initial; border-color:initial; font-size:14px; vertical-align:baseline; background-color:transparent; color:#000000 .<span class="pln" style="margin-bottom:0px; padding-bottom:0px; border-right-width:0px; border-bottom-width:0px; border-left-width:0px; border-style:initial; border-color:initial; font-size:14px; vertical-align:baseline; background-color:transparent; color:#000000 end<span class="pun" style="margin-bottom:0px; padding-bottom:0px; border-right-width:0px; border-bottom-width:0px; border-left-width:0px; border-style:initial; border-color:initial; font-size:14px; vertical-align:baseline; background-color:transparent; color:#000000 ();<span class="pln" style="margin-bottom:0px; padding-bottom:0px; border-right-width:0px; border-bottom-width:0px; border-left-width:0px; border-style:initial; border-color:initial; font-size:14px; vertical-align:baseline; background-color:transparent; color:#000000 <span class="pun" style="margin-bottom:0px; padding-bottom:0px; border-right-width:0px; border-bottom-width:0px; border-left-width:0px; border-style:initial; border-color:initial; font-size:14px; vertical-align:baseline; background-color:transparent; color:#000000 ++<span class="pln" style="margin-bottom:0px; padding-bottom:0px; border-right-width:0px; border-bottom-width:0px; border-left-width:0px; border-style:initial; border-color:initial; font-size:14px; vertical-align:baseline; background-color:transparent; color:#000000 it<span class="pun" style="margin-bottom:0px; padding-bottom:0px; border-right-width:0px; border-bottom-width:0px; border-left-width:0px; border-style:initial; border-color:initial; font-size:14px; vertical-align:baseline; background-color:transparent; color:#000000 )[/code][/code]
http://stackoverflow.com/questions/795987/c-iterators-loop-optimization
What I wanna know here, is the official MS-specific answer for this question, since I only use visual studio both at work/home.<br/>
My little research was that(under VS2012): the release version will be the same for both if dont consider different register usage; there will be difference which cause the first version more efficient if I put __declspec(noinline) before vector::end().
BTW, whats the equivalent pragma/declspec for normal non-member function to not get inlined?<br/>
http://stackoverflow.com/questions/795987/c-iterators-loop-optimization
PS: I know the first would be wrong if end() actually gets changed inside loop, lets just consider the situation where end() is const through the loop. http://stackoverflow.com/questions/795987/c-iterators-loop-optimization <hr class="sig I am a passionate game programmer.
View the full article