Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>1. Memory localization. Guaranteed contiguous. I noticed you clarified that variables mat1, and mat2, are int**. But how is matrix_ handled in memory. Interators just point anywhere conceivably. Is your memory for matrix_ localized? Heap based multidimensional arrays may not be contiguous. But Vector&lt;> is.</p> <p>This line of code isn't using the actual interators, but using their variables to index an array that is localized.</p> <pre><code>mat2[mat2Begin.y_][mat2Begin.x_] = f(mat1[mat1Begin.y_][mat1Begin.x_]); </code></pre> <p>2. You're forgetting optimizations. In the second usage of using the incrementing operator, you're doing that step before calling the functor.</p> <p>This may mean that calling the functor passing it an object that is dereferenced through the operator is interfering with the optimizers ability to prioritize order.</p> <p>Try storing off the dereferenced object before calling op() on it, and see if that eliminates the cost.</p> <pre><code>for (; first1 != last1; ++first1, ++result) { InputIterator::value_type val = *first1; *result = op(val); } </code></pre> <p>I've seen some funky things with using operators on argument assignment. To the point where it's deferred resolving until after the call even (sending in some other interpretation of the expression, and resolving the expression after the call), and argument resolution order is not guaranteed. It's best to send the actual intended object through the argument if you have efficiency problems.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload