[PATCH] D12355: [libcxx] Optimize away unneeded length calculation in basic_string::compare(const char*)
Marshall Clow via cfe-commits
cfe-commits at lists.llvm.org
Thu Aug 27 07:48:11 PDT 2015
mclow.lists added inline comments.
================
Comment at: include/string:3801
@@ -3799,1 +3800,3 @@
+ if (__lhs_len != __rhs.size()) return false;
+ return _Traits::compare(__rhs.data(), __lhs, _VSTD::min(__lhs_len, __rhs.size())) == 0;
}
----------------
If the lengths are the same (and they are), you don't need the `min` of them
================
Comment at: include/string:3802
@@ -3799,2 +3801,3 @@
+ return _Traits::compare(__rhs.data(), __lhs, _VSTD::min(__lhs_len, __rhs.size())) == 0;
}
----------------
Also, you should not call `traits::compare` here. You should call `__rhs.compare(0, npos, __lhs, __lhs_len)`
which is what `__rhs.compare(__lhs)` does.
http://reviews.llvm.org/D12355
More information about the cfe-commits
mailing list