What is the fastest method, to compare two u_int64[8]
arrays in C/C++ ?
Array 1 is inside a std::vector
(~10k elements) array 2 is inside a dynamic allocated struct. (is memcmp()
here false positive free?)
My (pseudo C) implementation :
typedef struct {
u_int64_t array[8];
}work_t;
/* alloc and fill array work_t* work = new (std::nothrow) work_t etc... */
for(u_int32_t i=0; i < some_std_vector.size(); i++) {
if((some_std_vector[i]->array[0] == work->array[0]) &&
(some_std_vector[i]->array[1] == work->array[1]) &&
(some_std_vector[i]->array[2] == work->array[2]) &&
(some_std_vector[i]->array[3] == work->array[3]) &&
(some_std_vector[i]->array[4] == work->array[4]) &&
(some_std_vector[i]->array[5] == work->array[5]) &&
(some_std_vector[i]->array[6] == work->array[6]) &&
(some_std_vector[i]->array[7] == work->array[7])) {
//...do some stuff...
}
}
The target platform is Linux x86_64 gcc 4.9.2, the loop is inside a pthread
, tcmalloc
is used, and the code is compiled with -O2