osrm-backend/data_structures
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
..
binary_heap.hpp Modernize the code base to C++11 standards and beyond. 2015-08-18 12:56:34 +02:00
compressed_edge_container.cpp Rename GeometryCompressor and add unit tests 2015-07-01 18:07:29 +02:00
compressed_edge_container.hpp Rename GeometryCompressor and add unit tests 2015-07-01 18:07:29 +02:00
concurrent_queue.hpp change copyright line from personal names to project 2015-02-19 09:19:51 +01:00
coordinate.cpp Move calculate_coordinate to algorithms/ 2015-08-12 13:02:18 +02:00
deallocating_vector.hpp Implement correct const iterator for DeallocatingVector 2015-08-06 11:13:25 +02:00
dynamic_graph.hpp Fix processing for data files with incorrect node references 2015-09-10 12:22:03 +02:00
edge_based_node.hpp Remove unused memebers and rename to currrent style convention 2015-07-01 18:07:29 +02:00
external_memory_node.cpp change copyright line from personal names to project 2015-02-19 09:19:51 +01:00
external_memory_node.hpp change copyright line from personal names to project 2015-02-19 09:19:51 +01:00
fixed_point_number.hpp change copyright line from personal names to project 2015-02-19 09:19:51 +01:00
hidden_markov_model.hpp Fix endless loop 2015-09-03 17:02:34 +02:00
hilbert_value.cpp Fixes undefined behavior from shifting into signed bit; use unsigned literal instead 2015-09-06 01:11:54 +02:00
hilbert_value.hpp change copyright line from personal names to project 2015-02-19 09:19:51 +01:00
import_edge.cpp Remove unused memebers and rename to currrent style convention 2015-07-01 18:07:29 +02:00
import_edge.hpp Remove unused memebers and rename to currrent style convention 2015-07-01 18:07:29 +02:00
internal_route_result.hpp change copyright line from personal names to project 2015-02-19 09:19:51 +01:00
lru_cache.hpp change copyright line from personal names to project 2015-02-19 09:19:51 +01:00
matrix_graph_wrapper.hpp fix some small issues: 2015-09-01 15:20:35 +02:00
node_based_graph.hpp Restructure the construction of the undirected graph 2015-07-01 18:07:29 +02:00
node_id.hpp change copyright line from personal names to project 2015-02-19 09:19:51 +01:00
original_edge_data.hpp change copyright line from personal names to project 2015-02-19 09:19:51 +01:00
percent.hpp change copyright line from personal names to project 2015-02-19 09:19:51 +01:00
phantom_node.cpp change copyright line from personal names to project 2015-02-19 09:19:51 +01:00
phantom_node.hpp Fix off-by one error in decoder and make padding deterministic. 2015-09-14 23:01:38 +02:00
query_edge.hpp Modernize the code base to C++11 standards and beyond. 2015-08-18 12:56:34 +02:00
query_node.hpp change copyright line from personal names to project 2015-02-19 09:19:51 +01:00
range_table.hpp change copyright line from personal names to project 2015-02-19 09:19:51 +01:00
raster_source.cpp Implement raster source feature to read data from third-party sources, to be used in lua profiles. 2015-09-03 22:28:18 -07:00
raster_source.hpp Implement raster source feature to read data from third-party sources, to be used in lua profiles. 2015-09-03 22:28:18 -07:00
rectangle.hpp Move calculate_coordinate to algorithms/ 2015-08-12 13:02:18 +02:00
restriction_map.cpp change copyright line from personal names to project 2015-02-19 09:19:51 +01:00
restriction_map.hpp Move graph compression code outside of EBGF 2015-07-01 18:07:29 +02:00
restriction.hpp Add documentation to InputRestrictionContainer 2015-04-21 20:00:58 +02:00
route_parameters.cpp Don't pass by const-value for a read-only view. 2015-09-08 23:34:20 +02:00
search_engine_data.cpp use CRTP instead of virtual functions in routing plugins 2015-03-02 11:55:55 +01:00
search_engine_data.hpp use CRTP instead of virtual functions in routing plugins 2015-03-02 11:55:55 +01:00
search_engine.hpp Initial version of core ch 2015-08-01 18:00:48 +02:00
segment_information.hpp Modernize the code base to C++11 standards and beyond. 2015-08-18 12:56:34 +02:00
shared_memory_factory.hpp Modernize the code base to C++11 standards and beyond. 2015-08-18 12:56:34 +02:00
shared_memory_vector_wrapper.hpp change copyright line from personal names to project 2015-02-19 09:19:51 +01:00
static_graph.hpp Allow any input format for StaticGraph and check if edge list is sorted 2015-08-06 11:13:25 +02:00
static_kdtree.hpp change copyright line from personal names to project 2015-02-19 09:19:51 +01:00
static_rtree.hpp Caches iterators instead of invoking function calls on every iteration. 2015-09-15 12:09:39 +02:00
travel_mode.hpp change copyright line from personal names to project 2015-02-19 09:19:51 +01:00
tribool.hpp change copyright line from personal names to project 2015-02-19 09:19:51 +01:00
turn_instructions.hpp change copyright line from personal names to project 2015-02-19 09:19:51 +01:00
upper_bound.hpp change copyright line from personal names to project 2015-02-19 09:19:51 +01:00
xor_fast_hash_storage.hpp change copyright line from personal names to project 2015-02-19 09:19:51 +01:00
xor_fast_hash.hpp change copyright line from personal names to project 2015-02-19 09:19:51 +01:00