We were stuck on the 4.5.0 tag from develop, since we searched for the
latest tag, but release tags are done on the master branch.
This commit rips out all the code for deriving the version on git tags.
Instead, we define major, minor, and patch versions in the CMakeLists
and then pass it on to:
- the `libosrm.pc` `pkg-config` file
- a `version.hpp` header that makes use of the preprocessor's string
concatenation to provide an easy way for generating version string
literals such as "v4.8.0".
That is, in the source code please now use the following defines:
#define OSRM_VERSION_MAJOR "@OSRM_VERSION_MAJOR@"
#define OSRM_VERSION_MINOR "@OSRM_VERSION_MINOR@"
#define OSRM_VERSION_PATCH "@OSRM_VERSION_PATCH@"
#define OSRM_VERSION "v" OSRM_VERSION_MAJOR "." OSRM_VERSION_MINOR "." OSRM_VERSION_PATCH
This rips out the Bost Spirit / Karma conversion code, using the stdlib
and lightweight alternatives instead.
The main benefit is an immense decrease in compilation times, for every
translation unit that requires the `util/cast.hpp` header.
Note: compared to the version before, there is a minor change in
behavior: the double `-0` was printed as `0` before and is now printed
as `-0`. This comes from the IEE754 standard, specifying signed zeros,
that is `+0` and `-0`. Interesting for us: JavaScript uses IEE754,
resulting in no breakage if used in arithmetic.
Small test case, left hand side was before, right hand side is now:
$ ./a.out
-1.123457 vs -1.123457
-1 vs -1
-1.3 vs -1.3
0 vs -0
0 vs 0
0 vs 0
1.3 vs 1.3
1.123457 vs 1.123457
References:
- https://en.wikipedia.org/wiki/Signed_zero
- http://www.boost.org/doc/libs/1_59_0/doc/html/boost/algorithm/trim_right_if.html
- http://www.boost.org/doc/libs/1_59_0/doc/html/boost/algorithm/is_any_of.html
With C++11 the stdlib gains:
- `std::stoi` function family to convert from `std::string` to integral type
- `std::to_string` to convert from number types to `std::string`
The only reason for hand-writing the conversion code therefore is
performance. I benchmarked an `osrm-extract` with the hand-written code
against one with the stdlib conversion features and could not find any
significant difference (we switch back and forth between C++ and Lua,
shaving off a few us in conversion doesn't gain us much).
Formatting arithmetic types in the default format with given precision
requires streams, but is doable in a few lines of idiomatic stdlib code.
For this, there is now the following function template available:
template <Arithmetic T, int Precision = 6>
inline std::string to_string_with_precision(const T);
that requires integral or floating point types and returns a formatted
string in the defaukt format with the given precision applied.
In addition this completely rips out Boost.Spirit from the `casts.hpp`
header, resulting in faster compile times.
Boom!
References:
- http://en.cppreference.com/w/cpp/string/basic_string/stol
- http://en.cppreference.com/w/cpp/string/basic_string/to_string
- http://www.kumobius.com/2013/08/c-string-to-int/
We needed this for Boost < 1.48, but per our Wiki on building OSRM:
> On Ubuntu 12.04 you will be limited to OSRM tag v0.3.10 because
> later versions **require Boost v1.49+** and installing this
> causes problems with libluabind-dev package.
Thus, rip it out!
To keep the commits atomic and isolated, I also refactored all call
sites that used the functionality from the portability fix.
While doing this, I also simplified the monster of around ~100 lines of
file path checking --- lambda's are awesome' use them!
References:
- http://stackoverflow.com/a/1750710
- https://github.com/Project-OSRM/osrm-backend/wiki/Building-on-Ubuntu
- removes `noexcept` specifier as we can not guarantee for not throwing
- uses a namespace instead of a struct + static function combination
- asserts for heading degree in [0, 360] range (both sides inclusive!)
- header only since implementation does not hide anything
- adds `inline` specifier as compiler hint
This removes the custom `replaceAll` function, replacing it with
`std::replace` from the stdlib's `<algorithm>` header.
This also removes the respective unit test.
More importantly, this removes the dependency on the
`<boost/algorithm/string.hpp>` header in the `string_util.hpp` header.
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
remove empty unit test
remove compiler directives
move trip related files from routing_algorithms to algorithms
run clang-format on files
fix all std::size_t related issues
improve code by adding std::move()s
clean up includes
fixing several code stye and improvement issues
add several small code improvements
return single scc in SplitUnaccessibleLocations() when theres only one
change ComputeRoute() to return an InternalRouteResult by value
improve some code style issues
Apply `clang-modernize` (based on Clang 3.6) transformations to the
codebase while making sure to support Clang>=3.4 and GCC>=4.8.
We apply the transformations in parallel to speed up the quite
time consuming process, and use our `clang-format` style file
to automatically format the code respecting our coding conventions.
We use the following self-explanatory transformations:
* AddOverride
* LoopConvert
* PassByValue
* ReplaceAutoPtr
* UseAuto
* UseNullptr
This required a `compile_commands.json` compilation database, e.g.
ccmake .. -DCMAKE_BUILD_TYPE=Release -DCMAKE_EXPORT_COMPILE_COMMANDS=1
for CMake or check Bear for a Makefile based solution (or even Ninja).
git ls-files -x '*.cpp|*.h' | \
xargs -I{} -P $(nproc) clang-modernize -p build -final-syntax-check -format -style=file -summary -for-compilers=clang-3.4,gcc-4.8 -include . -exclude third_party {}
Boom!
References:
* http://clang.llvm.org/extra/clang-modernize.html
* http://clang.llvm.org/extra/ModernizerUsage.html
Symbolic links are a _bad_ idea with lua script. Lua will search at the
place of the symbolic link for modules _not_ at the actual location of
the script.