Changeset 1837
 Timestamp:
 Jan 7, 2012, 6:13:57 PM (7 years ago)
 File:

 1 edited
Legend:
 Unmodified
 Added
 Removed

trunk/lib/byte_compare.hpp
r1836 r1837 19 19 Otherwise results are not valid due to pointer casts. 20 20 21 TODO  STATIC ASSERT  sizeof(T) <= L 22 21 23 */ 22 24 … … 31 33 using namespace std; 32 34 33 template<class T> 34 IDISA_ALWAYS_INLINE bool compare(const T * x, const T * y, const uint32_t offset); 35 template<class T, uint32_t L> IDISA_ALWAYS_INLINE bool overlap_compare(const T * x, const T * y); 36 template<class T> IDISA_ALWAYS_INLINE bool compare(const T * x, const T * y, const uint32_t offset); 37 IDISA_ALWAYS_INLINE bool mem_compare(const unsigned char * x, const unsigned char * y, uint32_t lgth); 38 35 39 36 40 template<class T, uint32_t L> … … 53 57 54 58 template<class T> 59 IDISA_ALWAYS_INLINE bool overlap_compare(const uint8_t * x, const uint8_t * y, uint32_t lgth) { 60 61 bool accum = true; 62 T * p_x = (T*) x; 63 T * p_y = (T*) y; 64 65 for(int i=0; i < lgth/sizeof(T); i++) { 66 accum = accum && compare(p_x,p_y,0); 67 p_x++; 68 p_y++; 69 } 70 if(lgth & (sizeof(T)1)) { 71 accum = accum && compare(x,y,lgthsizeof(T)); 72 } 73 return accum; 74 } 75 76 template<class T> 55 77 IDISA_ALWAYS_INLINE bool compare(const T * x, const T * y, const uint32_t offset) { 56 78 return !((*((T*)((uint8_t *)x + offset))) ^ … … 65 87 } 66 88 89 IDISA_ALWAYS_INLINE bool mem_compare(const unsigned char * x, const unsigned char * y, uint32_t lgth) { 90 return (0 == memcmp(x, y, lgth)); 91 } 92 93 67 94 #endif // BYTE_COMPARE_HPP 68 95
Note: See TracChangeset
for help on using the changeset viewer.