Should libcpp functions such as std::array::operator[]
be marked always_inline
?
#110367
Labels
libc++
libc++ C++ Standard Library. Not GNU libstdc++. Not libc++abi.
The recent article "std::array in C++ isn't slower than array in C" measures
std::array
accesses having a significant run-time overhead with optimizations disabled, which is the norm for debug builds.This is nothing new -- especially among the game developer community, the use of Standard Library abstractions such as
std::array
andstd::vector
is frowned upon due to their run-time overhead in debug builds.A possible solution to debug overhead of containers such as
std::array
would be marking operations that (1) are commonly used in hot loops and (2) are simple/trivial as_LIBCPP_ALWAYS_INLINE
. An example isstd::array::operator[]
.Would it make sense to mark such functions with with
_LIBCPP_ALWAYS_INLINE
?I cannot really think of any realistic drawback. Even with libcpp assertions enabled, I cannot think of a reasonable situation where all the following conditions apply:
std::array
accessSo the potentially increased code size wouldn't be an issue in practice. Thoughts?
The text was updated successfully, but these errors were encountered: