Changeset 1871


Ignore:
Timestamp:
Jan 21, 2012, 2:21:44 PM (7 years ago)
Author:
ksherdy
Message:

Added conditional.

Location:
trunk/lib
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/lib/byte_util.hpp

    r1869 r1871  
    1515static IDISA_ALWAYS_INLINE T slice(const uint8_t * buffer, const uint32_t pos, const uint32_t lgth) {
    1616
    17     T shift = *((T *)(buffer+pos)); // >> (pos * SF);
     17    T shift = *((T *)(buffer+pos));
    1818
    19     // if(lgth != sizeof(T)) {
     19    if(lgth != sizeof(T)) {
    2020
    21     const T ZERO  = 0;
    22     T mask = ~(~ZERO << (lgth * SF));
    23     return shift & mask;
     21        const T ZERO  = 0;
     22        T mask = ~(~ZERO << (lgth * SF));
     23        return shift & mask;
    2424
    25     // }  else { return shift; }
     25    }
    2626
     27    return shift;
    2728}
    2829
  • trunk/lib/test/byte_util_test.cpp

    r1867 r1871  
    99    uint64_t r = 0;
    1010    uint64_t max_lgth = sizeof(r);
    11     for(uint32_t lgth = 1;lgth<max_lgth;lgth++) {
     11    for(uint32_t lgth = 1;lgth<max_lgth+1;lgth++) {
    1212        for(uint32_t pos=0;pos<max_lgth-lgth+1;pos++) {
    1313             r = slice<uint64_t,8>((uint8_t *)buffer, pos, lgth);
     
    2121    }
    2222
    23 
    2423    return 1;
    2524}
Note: See TracChangeset for help on using the changeset viewer.