[PATCH] D27068: Improve string::find

Tim Song via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Dec 1 11:46:06 PST 2016


tcanens added inline comments.


================
Comment at: include/__string:543
+_LIBCPP_CONSTEXPR_AFTER_CXX11
+_RandomAccessIterator
+__search_substring(_RandomAccessIterator __first1, _RandomAccessIterator __last1,
----------------
A character traits class need only accept pointers, so the name `_RandomAccessIterator` is misleading when you are passing them directly to `_Traits::find`/`_Traits::compare`. Why not just `const _CharT*`? Then you can strip out all the `iterator_traits` circumlocution as well.


================
Comment at: include/__string:548
+    using __iterator_traits = iterator_traits<_RandomAccessIterator>;
+    typedef typename __iterator_traits::difference_type __difference_type;
+
----------------
For example, since `_RandomAccessIterator` must be a pointer type, this can't possibly be anything other than `ptrdiff_t`.


================
Comment at: include/__string:568
+      __first1 = _Traits::find(__first1, __len1 - __len2 + 1, __f2);
+      if (__first1 == _RandomAccessIterator(0))
+        return __last1;
----------------
The function-style cast is redundant.


https://reviews.llvm.org/D27068





More information about the cfe-commits mailing list