James Y Knight via llvm-dev
2016-Dec-02 17:12 UTC
[llvm-dev] RFC: Constructing StringRefs at compile time
On Fri, Dec 2, 2016 at 6:35 AM, Malcolm Parsons via llvm-dev < llvm-dev at lists.llvm.org> wrote:> On 29 November 2016 at 17:52, Malcolm Parsons <malcolm.parsons at gmail.com> > wrote: > > On 29 November 2016 at 17:38, Zachary Turner <zturner at google.com> wrote: > >> I see, but I looked over your proposed implementation from earlier in > the > >> thread, and if I'm not mistaken I see this: > > > > That's a different suggestion. > > llvm_strlen could be something like this: > > #if __cpp_lib_constexpr_char_traits > constexpr size_t llvm_strlen(const char *S) { > return std::char_traits<char>::length(S); > } > #elif __has_builtin(__builtin_strlen) || defined(__GNUC__) > constexpr size_t llvm_strlen(const char *S) { return __builtin_strlen(S); } > #elif __cpp_constexpr >= 201304 > constexpr size_t llvm_strlen(const char *S) { > const char *const A = S; > while (*S != '\0') { > ++S; > } > return S - A; > } > #else > constexpr size_t llvm_strlen(const char *S, size_t L = 0) { > return *S ? llvm_strlen(S + 1, L + 1) : L; > } > #endif >...and we've gone in a loop in this conversation, haven't we? Isn't this again where you end up with really slow code for compilers that end up in the last #else, such as MSVC? +1 from me for the StringLiteral proposal from a few messages back. -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20161202/248eb92b/attachment.html>
Malcolm Parsons via llvm-dev
2016-Dec-09 09:17 UTC
[llvm-dev] RFC: Constructing StringRefs at compile time
On 2 December 2016 at 17:12, James Y Knight <jyknight at google.com> wrote:> +1 from me for the StringLiteral proposal from a few messages back.Zachary, do you want to commit StringLiteral? -- Malcolm Parsons
Zachary Turner via llvm-dev
2016-Dec-12 19:53 UTC
[llvm-dev] RFC: Constructing StringRefs at compile time
I can. I'll whip something up today On Fri, Dec 9, 2016 at 1:18 AM Malcolm Parsons <malcolm.parsons at gmail.com> wrote:> On 2 December 2016 at 17:12, James Y Knight <jyknight at google.com> wrote: > > +1 from me for the StringLiteral proposal from a few messages back. > > Zachary, do you want to commit StringLiteral? > > -- > Malcolm Parsons >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20161212/e7fa014e/attachment.html>