title: Is it more efficient to store vector size into an int variable when using it multiple times?
body: <p>So if we have the code below:</p>
  
  <pre><code>vector&lt;string&gt; vec1;
  //initialize vec1 to contain thousands of strings
  
  for (int i = 0; i &lt; vec1.size(); i++) {
      //.....
  }
  
  for (int j = 0; j &lt; vec1.size(); j++){
     //......
  }
  </code></pre>
  
  <p>Would it be faster to declare an int vec_size = vec1.size() and use it like so:</p>
  
  <pre><code>int vec_size = vec1.size();
  
  for (int i = 0; i &lt; vec_size; i++) {
          //.....
      }
  
  for (int j = 0; j &lt; vec_size; i++) {
          //.....
      }
  </code></pre>
  
  <p>and if so, why?</p>