Should I refer std::vector size when the number is explicitly given
<p>I'm coding a simple function using std::vector below where input is an integer vector and the function proceeds the iteration based on the number of elements in the vector.</p>

<p>In terms of space and time efficiency, which following code are suitable?
HugeClass is actually a Big Integer which contains complex arithmetic while I put a simple arithmetic below for simplicity.</p>

<p>1) Gives a dimension of vector </p>

<pre><code>void (HugeClass&amp; huge, std::vector&lt;int&gt;&amp; vec, int dim){
    for(int i=0;i&lt;dim;i++){
        huge+=vec[i];
    }
}
</code></pre>

<p>2) Calls a std::vector.size() to iterate  </p>

<pre><code>void (HugeClass&amp; huge, std::vector&lt;int&gt;&amp; vec){
    for(int i=0;i&lt;vec.size();i++){
        huge+=vec[i];
    }
}
</code></pre>

<p>dim can range in [100,1000000]</p>