osrm-backend/contractor
Daniel J. Hofmann 94af9b7f13 Caches iterators instead of invoking function calls on every iteration.
This caches iterators, i.e. especially the end iterator when possible.

The problem:

    for (auto it = begin(seq); it != end(seq); ++it)

this has to call `end(seq)` on every iteration, since the compiler is
not able to reason about the call's site effects (to bad, huh).

Instead do it like this:

    for (auto it = begin(seq), end = end(seq); it != end; ++it)

caching the end iterator.

Of course, still better would be:

    for (auto&& each : seq)

if all you want is value semantics.

Why `auto&&` you may ask? Because it binds to everything and never copies!

Skim the referenced proposal (that was rejected, but nevertheless) for a
detailed explanation on range-based for loops and why `auto&&` is great.

Reference:

- http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2014/n3853.htm
2015-09-15 12:09:39 +02:00
..
contractor_options.cpp Serialize out .core file containing core node markers 2015-08-19 12:27:44 +02:00
contractor_options.hpp Serialize out .core file containing core node markers 2015-08-19 12:27:44 +02:00
contractor.hpp Caches iterators instead of invoking function calls on every iteration. 2015-09-15 12:09:39 +02:00
edge_based_graph_factory.cpp Fix Coverity warning in EBGF 2015-08-20 12:28:14 +02:00
edge_based_graph_factory.hpp Modernize the code base to C++11 standards and beyond. 2015-08-18 12:56:34 +02:00
processing_chain.cpp Use iterator pair taking parallel_sort, old TBB versions have no range overload. 2015-09-10 11:04:50 +02:00
processing_chain.hpp Ownership: vector already owns, no need for wrapping in unique_ptr. 2015-09-09 18:53:11 +02:00
speed_profile.hpp Move graph compression code outside of EBGF 2015-07-01 18:07:29 +02:00