title: Significant runtime increase after employing list::size()
body: <p>I have a huge code size. I recently added some new code and it works fine until I added a new simple if statement. After adding this add statement the runtime increases by 100X which is nonsense.</p>
  
  <p>Some part of my code is below. The if statement is added in terminate_ongoing function and even if I remove everything inside if statement, the program is still slow. But if I comment this if statement, it becomes fast again. </p>
  
  <p>The if statement is </p>
  
  <pre><code>if ( emitted_vulnerable_list.size() &gt; 100000 ){
  }
  </code></pre>
  
  <p>As you can see, I removed everything inside if, but the problem is not resolved. Could you please provide some hints to find the source of problem and solve it.</p>
  
  <pre><code>class flip_flop_vulnerable_time{
  public:
     list &lt;vulnerable_time&gt; emitted_vulnerable_list;
     list &lt;vulnerable_time&gt; ongoing_vulnerable_list;
  
  
     void terminate_ongoing(int PO, int minimum_delay , int cycle, long long elimination_time){
       for (list&lt;vulnerable_time&gt;::iterator it=ongoing_vulnerable_list.begin(); it!=ongoing_vulnerable_list.end(); it++){
         if ( it-&gt; PO_signal_number == PO &amp;&amp; it-&gt;cycles_passed == cycle &amp;&amp; it-&gt;min_delay == minimum_delay ){
           it-&gt; elimination_time = elimination_time;
           if ( cycle == 0 &amp;&amp; elimination_time - it-&gt;appearance_time &lt; 500 )
             ongoing_vulnerable_list.erase(it);
           else{
             emitted_vulnerable_list.splice(emitted_vulnerable_list.end(),ongoing_vulnerable_list, it);
             if ( emitted_vulnerable_list.size() &gt; 100000 ){
             }
           }
           return;
         }
       }
       cout&lt;&lt;"\tError: can't find the following ongoing vulnerable_time object"&lt;&lt;endl;
       exit(0);
     }
  
     // Some other functions here
  };
  </code></pre>