VirtualBox

Ignore:
Timestamp:
Jul 5, 2014 10:51:29 PM (11 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
94742
Message:

alt-sha1.cpp: Save an operation in both Ch() and Maj(). The Maj optimization is easier to figure out than the Ch() one.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Runtime/common/checksum/alt-sha1.cpp

    r51878 r51879  
    131131DECL_FORCE_INLINE(uint32_t) rtSha1Ch(uint32_t uX, uint32_t uY, uint32_t uZ)
    132132{
     133#if 1
     134    /* Optimization that saves one operation and probably a temporary variable. */
     135    uint32_t uResult = uY;
     136    uResult ^= uZ;
     137    uResult &= uX;
     138    uResult ^= uZ;
     139    return uResult;
     140#else
     141    /* The original. */
    133142    uint32_t uResult = uX & uY;
    134143    uResult ^= ~uX & uZ;
    135144    return uResult;
     145#endif
    136146}
    137147
     
    150160DECL_FORCE_INLINE(uint32_t) rtSha1Maj(uint32_t uX, uint32_t uY, uint32_t uZ)
    151161{
     162#if 1
     163    /* Optimization that save one operation and probably a temporary variable. */
     164    uint32_t uResult = uY;
     165    uResult ^= uZ;
     166    uResult &= uX;
     167    uResult ^= uY & uZ;
     168    return uResult;
     169#else
     170    /* The original. */
    152171    uint32_t uResult = (uX & uY);
    153172    uResult |= (uX & uZ);
    154173    uResult |= (uY & uZ);
    155174    return uResult;
     175#endif
    156176}
    157177
Note: See TracChangeset for help on using the changeset viewer.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette