[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 05:26:59 PDT 2021


prehistoric-penguin added inline comments.


================
Comment at: libcxx/include/bitset:778
         _CharT __c = __str[_Mp - 1 - __i];
         if (__c == __zero)
             (*this)[__i] = false;
----------------
curdeius wrote:
> When here, please update this part too.
I have fixed this part. The CI fail is caused by the clang-format checking, it has nothing to do with my change.


================
Comment at: libcxx/include/bitset:806
         _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);
     }
----------------
curdeius wrote:
> I assume that there's no subtle difference between `_Traits::eq(__c, __one)` and `!_Traits::eq(__c, __zero)`, right?
Yes, there are only two possible values `__one` and `__zero`


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D100828/new/

https://reviews.llvm.org/D100828



More information about the libcxx-commits mailing list