diff options
author | 2020-09-25 21:44:39 +0200 | |
---|---|---|
committer | 2020-09-25 21:44:54 +0200 | |
commit | 15ea16e1497bcd28168f5c8ba2e53d3a8da8350c (patch) | |
tree | ce7cc28d5d0a6034e60292691c5f97276e11a353 /src/lib/netlist/plib/pgsl.h | |
parent | dcc2781365cc194fbbd0383269bc1399f48de18a (diff) |
netlist: minor code cleanup.
* a number of minor fixes leading to an increase of 570% to 588% on
pongf.
* admittedly micro optimization.
* Includes some comments why certain decisions have been taken.
Diffstat (limited to 'src/lib/netlist/plib/pgsl.h')
-rw-r--r-- | src/lib/netlist/plib/pgsl.h | 22 |
1 files changed, 18 insertions, 4 deletions
diff --git a/src/lib/netlist/plib/pgsl.h b/src/lib/netlist/plib/pgsl.h index 1ea8622d19c..4ddc957b9ac 100644 --- a/src/lib/netlist/plib/pgsl.h +++ b/src/lib/netlist/plib/pgsl.h @@ -36,10 +36,24 @@ #define gsl_Expects(e) ((e) ? static_cast<void>(0) : static_cast<void>(0)) #endif -#if 0 +#if 1 +// FIXME: __builtin_unreachable contrary to google sources does not seem to be of +// any use and decreases performance slightly. Convert gsl_Expects to a noop +// and revisit in the future. #undef gsl_Expects #define gsl_Expects(e) do {} while (0) + +#if 0 +// Alternative and c++ style implementation. Suffers from the same drawbacks +// like __builtin_unreachable +static constexpr inline void gsl_Expects(const bool &e) +{ + if (!e) + __builtin_unreachable(); +} #endif +#endif + #define gsl_Ensures(e) gsl_Expects(e) namespace plib { @@ -56,7 +70,7 @@ namespace plib { /// \brief perform a narrowing cast without checks /// template <typename T, typename O> - inline constexpr T narrow_cast(O && v) noexcept + constexpr T narrow_cast(O && v) noexcept { static_assert(plib::is_arithmetic<T>::value && std::is_convertible<std::remove_reference_t<O>, T>::value, "narrow cast expects conversion between arithmetic types"); return static_cast<T>(std::forward<O>(v)); @@ -66,7 +80,7 @@ namespace plib { /// /// The c++ core guidelines require the narrow function to raise an error /// This will make narrow noexcept(false). This has shown to have a - /// measurable impact on performance and thus we deviate we deviate from + /// measurable impact on performance and thus we deviate from /// the standard here. /// template <typename T, typename O> @@ -86,7 +100,7 @@ namespace plib { } // namespace pgsl - /// \brief downcast from base tpye to derived type + /// \brief downcast from base type to derived type /// /// The cpp core guidelines require a very careful use of static cast /// for downcast operations. This template is used to identify these uses |