orlp / pdqsort

Pattern-defeating quicksort.
zlib License
2.37k stars 102 forks source link

inline swap_offsets, use diff_t type from iterator instead of size_t #24

Closed mdejong closed 1 year ago

mdejong commented 1 year ago

Greetings. I was not able to find a specific bug on my MacOSX (arm64) machine compiling with clang, but the use of size_t does not seem to be correct because the compiler could be using a 16 bit value for size_t. This patch uses only diff_t from the iterator instead and directly pulls in the code from the tiny swap_offsets method as that avoids passing diff_t. See https://en.cppreference.com/w/cpp/types/size_t

orlp commented 1 year ago

I really am not worried about compatibility with a compiler that provides a 16-bit size_t type on platforms with an address space larger than 16 bits.