From:

Date:

February 22, 2014 14:10Subject:

sv_grow and powers of two (or multiples of 256)Message ID:

20140222141013.18269.qmail@lists-nntp.develooper.comsv_grow has this comment: * If the new size is a big power of two, don't bother: we assume the * caller wanted a nice 2^N sized block and will be annoyed at getting * 2^N+1 */ if (newlen & 0xff) newlen++; But 'newlen & 0xff' checks that it is not a multiple of 256, not that it is not a power of 2, so the chances of skipping COW are greater than they ought to be. Is there any easy and efficient way to check for powers of 2 in C? The only way I can think of offhand is to loop and shift, checking whether 'foo>>n == 1 && foo>>n<<n == foo'. Is it worth that?Thread Next

**sv_grow and powers of two (or multiples of 256)**by Father Chrysostomos- Re: sv_grow and powers of two (or multiples of 256) by Brad Gilbert
- Re: sv_grow and powers of two (or multiples of 256) by Eric Brine
- Re: sv_grow and powers of two (or multiples of 256) by Eric Brine
- RE: sv_grow and powers of two (or multiples of 256) by bulk 88
- Re: sv_grow and powers of two (or multiples of 256) by perl
- Re: sv_grow and powers of two (or multiples of 256) by Steffen Mueller

nntp.perl.org: Perl Programming lists via nntp and http.

Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About