On Thu, 2018-08-23 at 06:26 -0400, Derrick Stolee wrote: > > Around the time that my proposed approaches were getting vetoed for > alignment issues, I figured I was out of my depth here. I reached out to > Daniel Lemire (of EWAH bitmap fame) on Twitter [1]. His blog is full of > posts of word-based approaches to different problems, so I thought he > might know something off the top of his head that would be applicable. > His conclusion (after looking only a short time) was to take a 'hasheq' > approach [2] like Peff suggested [3]. Since that requires auditing all > callers of hashcmp to see if hasheq is appropriate, it is not a good > solution for 2.19 but (in my opinion) should be evaluated as part of the > 2.20 cycle. > That was an interesting blog post, indeed. It had an interesting comments section. One comment especially caught my eyes was [a]: "So the way gcc (and maybe clang) handles this is specifically by recognizing memcmp and checking whether a only a 2-way result is needed and then essentially replacing it with a memcmp_eq call. ..." I find this to be an interesting note. It seems GCC does optimize when we clearly indicate that we use the result of the memcmp as a boolean. So would that help in anyway? Maybe it would help in writing a `hasheq` method easily? I'm not sure. > [1] https://twitter.com/stolee/status/1032312965754748930 > > [2] > https://lemire.me/blog/2018/08/22/avoid-lexicographical-comparisons-when-testing-for-string-equality/ > > [3] > https://public-inbox.org/git/20180822030344.GA14684@xxxxxxxxxxxxxxxxxxxxx/ > > [4] > https://public-inbox.org/git/7ea416cf-b043-1274-e161-85a8780b8e1c@xxxxxxxxx/ [a]: https://lemire.me/blog/2018/08/22/avoid-lexicographical-comparisons-when-testing-for-string-equality/#comment-344073 -- Sivaraam