On 12/26/22 23:25, Alejandro Colomar wrote: > Hi Noah, > > On 12/26/22 03:43, Noah Goldstein wrote: > >> I see. The code you commented earlier was NULL for both. > > I don't remember; maybe there was a typo... > >> >> Either way you can just make it: >> >> ``` >> if((dst - 1UL) >= (end - 1UL)) { > > I didn't expect that would be significantly better than `(dst == end || dst == > NULL)`.  However, I compiled both just to see, and the assembly output for your > code is shorter.  I'll benchmark both to see if there are performance differences. > > I wonder why the compiler doesn't generate this code if it's better; it has all > the information to decide that it can be transformed into that. > > Both clang and GCC produce better code with your suggestion (although in the > case of GCC, the difference is bigger. Self-correction: They produce smaller code for your suggestion, but it seems to be slower code. > > Cheers, > > Alex > >>   return dst; // either dst == NULL or dst == end. >> } >> ``` > > --