[lld] r210084 - No need to compute valBit until mask bit is 1.

Daniil Troshkov troshkovdanil at gmail.com
Tue Jun 3 02:06:16 PDT 2014


why are you choosing "bool maskBit" instead of "const bool maskBit"?


2014-06-03 11:39 GMT+04:00 Rui Ueyama <ruiu at google.com>:

> Author: ruiu
> Date: Tue Jun  3 02:39:32 2014
> New Revision: 210084
>
> URL: http://llvm.org/viewvc/llvm-project?rev=210084&view=rev
> Log:
> No need to compute valBit until mask bit is 1.
>
> Modified:
>     lld/trunk/include/lld/ReaderWriter/RelocationHelperFunctions.h
>
> Modified: lld/trunk/include/lld/ReaderWriter/RelocationHelperFunctions.h
> URL:
> http://llvm.org/viewvc/llvm-project/lld/trunk/include/lld/ReaderWriter/RelocationHelperFunctions.h?rev=210084&r1=210083&r2=210084&view=diff
>
> ==============================================================================
> --- lld/trunk/include/lld/ReaderWriter/RelocationHelperFunctions.h
> (original)
> +++ lld/trunk/include/lld/ReaderWriter/RelocationHelperFunctions.h Tue Jun
>  3 02:39:32 2014
> @@ -21,10 +21,10 @@ template <typename T> T gatherBits(T val
>    T result = 0;
>    size_t off = 0;
>
> -  for (size_t bit = 0; bit != sizeof(T) * 8; ++bit) {
> -    const bool valBit = (val >> bit) & 1;
> -    const bool maskBit = (mask >> bit) & 1;
> +  for (size_t bit = 0; bit < sizeof(T) * 8; ++bit) {
> +    bool maskBit = (mask >> bit) & 1;
>      if (maskBit) {
> +      bool valBit = (val >> bit) & 1;
>        result |= static_cast<T>(valBit) << off;
>        ++off;
>      }
> @@ -41,10 +41,10 @@ template <typename T> T scatterBits(T va
>    T result = 0;
>    size_t off = 0;
>
> -  for (size_t bit = 0; bit != sizeof(T) * 8; ++bit) {
> -    const bool valBit = (val >> off) & 1;
> -    const bool maskBit = (mask >> bit) & 1;
> +  for (size_t bit = 0; bit < sizeof(T) * 8; ++bit) {
> +    bool maskBit = (mask >> bit) & 1;
>      if (maskBit) {
> +      bool valBit = (val >> off) & 1;
>        result |= static_cast<T>(valBit) << bit;
>        ++off;
>      }
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20140603/e741fa4e/attachment.html>


More information about the llvm-commits mailing list