Skip to content

Commit 49497d8

Browse files
committed
Merge pull request opencv#17725 from pemmanuelviel:pev--precompute-divisor
2 parents 73f7d09 + 327f92c commit 49497d8

File tree

1 file changed

+9
-2
lines changed
  • modules/flann/include/opencv2/flann

1 file changed

+9
-2
lines changed

modules/flann/include/opencv2/flann/dist.h

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -506,7 +506,7 @@ struct Hamming2
506506
const uint64_t* pa = reinterpret_cast<const uint64_t*>(a);
507507
const uint64_t* pb = reinterpret_cast<const uint64_t*>(b);
508508
ResultType result = 0;
509-
size /= (sizeof(uint64_t)/sizeof(unsigned char));
509+
size /= long_word_size_;
510510
for(size_t i = 0; i < size; ++i ) {
511511
result += popcnt64(*pa ^ *pb);
512512
++pa;
@@ -516,7 +516,7 @@ struct Hamming2
516516
const uint32_t* pa = reinterpret_cast<const uint32_t*>(a);
517517
const uint32_t* pb = reinterpret_cast<const uint32_t*>(b);
518518
ResultType result = 0;
519-
size /= (sizeof(uint32_t)/sizeof(unsigned char));
519+
size /= long_word_size_;
520520
for(size_t i = 0; i < size; ++i ) {
521521
result += popcnt32(*pa ^ *pb);
522522
++pa;
@@ -525,6 +525,13 @@ struct Hamming2
525525
#endif
526526
return result;
527527
}
528+
529+
private:
530+
#ifdef FLANN_PLATFORM_64_BIT
531+
static const size_t long_word_size_ = sizeof(uint64_t)/sizeof(unsigned char);
532+
#else
533+
static const size_t long_word_size_ = sizeof(uint32_t)/sizeof(unsigned char);
534+
#endif
528535
};
529536

530537

0 commit comments

Comments
 (0)