On Tue, Sep 7, 2021 at 8:07 AM Ruediger Pluem <rpl...@apache.org> wrote:
>
> On 9/7/21 3:52 AM, yla...@apache.org wrote:
> >
> > -    /* Set counter in network byte order for the uuencoded unique id. */
> > -    new_unique_id.counter = htons(new_unique_id.counter);
> > +    /* The counter is two bytes for the uuencoded unique id, in network
> > +     * byte order.
> > +     */
> > +    new_unique_id.counter = htons(counter % APR_UINT16_MAX);
>
> Isn't '&' doing the same as '%' here and is more performant?

With a *literal* ^2-1 modulus, the compiler generates the exact same
code (a '&'). The modulo is possibly more readable..
But yeah, if the modulus were a variable, the '&' is clearly more performant.


Regards;
Yann.

Reply via email to