stefankarschti / inputosm

A high performance reader of OSM data files.
Other
2 stars 1 forks source link

Challenge: Convert to branchless #6

Open stefankarschti opened 1 year ago

stefankarschti commented 1 year ago

https://github.com/stefankarschti/inputosm/blob/8700abed527f863ca0d726045ccf1974795119c8/src/inputosmpbf.cpp#L123

possible solution:

`

inline int64_t to_sint64(uint64_t v64) noexcept { // original: // return (v64 & 1) ? -(int64_t)((v64 + 1) / 2) : (v64 + 1) / 2;

// branchless: return (int64_t)((v64 + 1) / 2) (1 - 2 (int64_t)(v64 & 1)); }

`