[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 01:51:10 PDT 2021


prehistoric-penguin created this revision.
prehistoric-penguin requested review of this revision.
Herald added a project: libc++.
Herald added a subscriber: libcxx-commits.
Herald added a reviewer: libc++.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D100828

Files:
  libcxx/include/bitset


Index: libcxx/include/bitset
===================================================================
--- libcxx/include/bitset
+++ libcxx/include/bitset
@@ -803,10 +803,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.338772.patch
Type: text/x-patch
Size: 515 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libcxx-commits/attachments/20210420/e753e900/attachment.bin>


More information about the libcxx-commits mailing list