[libcxx-commits] [PATCH] D100828: Remove if-else to make branch predictor happy
ppenguin via Phabricator via libcxx-commits
libcxx-commits at lists.llvm.org
Tue Apr 20 19:16:47 PDT 2021
prehistoric-penguin updated this revision to Diff 339074.
prehistoric-penguin added a comment.
The CI fails is caused by my mistake, for the previous function, we can't call the ` _Traits::eq` since the ` _Traits` doesn't exist in the function signature. Now the CI should pass, but the code change `(*this)[__i] = (__c == __one);` needs to be reviewed again, I don't know if it violates the code style.
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D100828/new/
https://reviews.llvm.org/D100828
Files:
libcxx/include/bitset
Index: libcxx/include/bitset
===================================================================
--- libcxx/include/bitset
+++ libcxx/include/bitset
@@ -775,10 +775,7 @@
for (; __i < _Mp; ++__i)
{
_CharT __c = __str[_Mp - 1 - __i];
- if (__c == __zero)
- (*this)[__i] = false;
- else
- (*this)[__i] = true;
+ (*this)[__i] = (__c == __one);
}
_VSTD::fill(base::__make_iter(__i), base::__make_iter(_Size), false);
}
@@ -803,10 +800,7 @@
for (; __i < _Mp; ++__i)
{
_CharT __c = __str[__pos + _Mp - 1 - __i];
- if (_Traits::eq(__c, __zero))
- (*this)[__i] = false;
- else
- (*this)[__i] = true;
+ (*this)[__i] = _Traits::eq(__c, __one);
}
_VSTD::fill(base::__make_iter(__i), base::__make_iter(_Size), false);
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D100828.339074.patch
Type: text/x-patch
Size: 853 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libcxx-commits/attachments/20210421/7a5b15b2/attachment-0001.bin>
More information about the libcxx-commits
mailing list