osrm-backend/util
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
..
bearing.cpp sprinkle a number of noexcepts into the code 2015-04-02 11:36:04 +02:00
bearing.hpp sprinkle a number of noexcepts into the code 2015-04-02 11:36:04 +02:00
boost_filesystem_2_fix.hpp change copyright line from personal names to project 2015-02-19 09:19:51 +01:00
cast.hpp sprinkle a number of noexcepts into the code 2015-04-02 11:36:04 +02:00
compute_angle.cpp sprinkle a number of noexcepts into the code 2015-04-02 11:36:04 +02:00
compute_angle.hpp sprinkle a number of noexcepts into the code 2015-04-02 11:36:04 +02:00
container.hpp MSVC doesnt properly support the noexcept operator 2015-04-02 15:11:23 +02:00
datastore_options.hpp Also support loading core information into shared memory 2015-08-19 12:27:44 +02:00
dist_table_wrapper.hpp fix some small issues: 2015-09-01 15:20:35 +02:00
fingerprint_impl.hpp.in Fix magic number check for fingerprint 2015-06-19 17:51:35 +02:00
fingerprint.cpp add (new) fingerprint.cpp that includes the generated headers 2015-03-31 10:47:21 +02:00
fingerprint.hpp Check if FingerPrint is trivial. TODO: Add this for all other data that is going to be serialized 2015-06-19 18:10:49 +02:00
floating_point.hpp change copyright line from personal names to project 2015-02-19 09:19:51 +01:00
git_sha.cpp.in change copyright line from personal names to project 2015-02-19 09:19:51 +01:00
git_sha.hpp change copyright line from personal names to project 2015-02-19 09:19:51 +01:00
graph_loader.hpp Fix magic number check for fingerprint 2015-06-19 17:51:35 +02:00
graph_utils.hpp Restructure the construction of the undirected graph 2015-07-01 18:07:29 +02:00
ini_file.hpp change copyright line from personal names to project 2015-02-19 09:19:51 +01:00
integer_range.hpp sprinkle a number of noexcepts into the code 2015-04-02 11:36:04 +02:00
iso_8601_duration_parser.hpp First step into overhauling the edge storage 2015-06-01 17:22:12 +02:00
iterator_range.hpp sprinkle a number of noexcepts into the code 2015-04-02 11:36:04 +02:00
json_logger.hpp Add option to enable json logging 2015-04-13 22:39:55 +02:00
json_renderer.hpp Caches iterators instead of invoking function calls on every iteration. 2015-09-15 12:09:39 +02:00
json_util.hpp Address some of the remaining issues of the code review 2015-03-04 01:34:45 +01:00
lua_util.hpp Follow symlinks 2015-05-15 15:30:41 +02:00
make_unique.hpp change copyright line from personal names to project 2015-02-19 09:19:51 +01:00
matching_debug_info.hpp Modernize the code base to C++11 standards and beyond. 2015-08-18 12:56:34 +02:00
mercator.cpp sprinkle a number of noexcepts into the code 2015-04-02 11:36:04 +02:00
mercator.hpp sprinkle a number of noexcepts into the code 2015-04-02 11:36:04 +02:00
osrm_exception.cpp change copyright line from personal names to project 2015-02-19 09:19:51 +01:00
osrm_exception.hpp Modernize the code base to C++11 standards and beyond. 2015-08-18 12:56:34 +02:00
range_algorithms.hpp fix license header 2015-02-26 18:54:13 +01:00
routed_options.hpp Add loading of .core file to InternalDataFacade 2015-08-19 12:27:44 +02:00
simple_logger.cpp change copyright line from personal names to project 2015-02-19 09:19:51 +01:00
simple_logger.hpp change copyright line from personal names to project 2015-02-19 09:19:51 +01:00
std_hash.hpp change copyright line from personal names to project 2015-02-19 09:19:51 +01:00
string_util.hpp Caches iterators instead of invoking function calls on every iteration. 2015-09-15 12:09:39 +02:00
timing_util.hpp change copyright line from personal names to project 2015-02-19 09:19:51 +01:00
trigonometry_table.hpp change copyright line from personal names to project 2015-02-19 09:19:51 +01:00
xml_renderer.hpp Caches iterators instead of invoking function calls on every iteration. 2015-09-15 12:09:39 +02:00