Add _LIBCPP_BUILTIN_CONSTANT_P support.
Summary: This change adds the macros _LIBCPP_COMPILER_HAS_BUILTIN_CONSTANT and _LIBCPP_BUILTIN_CONSTANT_P to detect compile time constants, and optimze the code accordingly. A planned usage example: The implementation of basic_string::assign() can short-cut a compile time known short string assignent into a fast and compact inlined assignment: ``` basic_string::assign(const value_type* __s) { if (_LIBCPP_BUILTIN_CONSTANT_P(__s[0]) && length(__s) < __min_cap) { copy(pointer(), _s, length(__s) + 1); set_size(length(__s)); } else { // delegate / tail call out of line implementation } } ``` Subscribers: christof, libcxx-commits Tags: #libc Differential Revision: https://reviews.llvm.org/D73732
Loading
Please register or sign in to comment