[libcxx-commits] [PATCH] D59999: Make it easier for the compiler to optimize `operator==(string, char*)`.
    Samuel Benzaquen via Phabricator via libcxx-commits 
    libcxx-commits at lists.llvm.org
       
    Fri Mar 29 14:21:14 PDT 2019
    
    
  
sbenza added a comment.
Thanks for debugging that. I didn't realize it didn't try to inline on purpose.
Maybe we just need to mark the function as `inline`, even if we also have the extern template instantiation.
That way the compiler can inline it if it helps, but won't actually generate the weak symbol in the object files otherwise.
Eg, something like:
  --- a/libcxx/include/string
  +++ b/libcxx/include/string
  @@ -3709,7 +3709,7 @@ basic_string<_CharT, _Traits, _Allocator>::compare(const basic_string& __str) co
   }
   
   template <class _CharT, class _Traits, class _Allocator>
  -int
  +inline int
   basic_string<_CharT, _Traits, _Allocator>::compare(size_type __pos1,
                                                      size_type __n1,
                                                      const value_type* __s,
does the same job without requiring changes to the implementation.
Repository:
  rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D59999/new/
https://reviews.llvm.org/D59999
    
    
More information about the libcxx-commits
mailing list