Skip to content

Commit 91faff1

Browse files
committed
On the user-defined-authn branch:
* auth/auth.c (find_next_user_scheme_type): Reduce four operations to just two, for the same result. Compilers optimize it that way -- might as well make it official. /Obviously/ this is on a critical path where every cycle counts. git-svn-id: https://svn.apache.org/repos/asf/serf/branches/user-defined-authn@1926126 13f79535-47bb-0310-9956-ffa450edef68
1 parent 3cb03c4 commit 91faff1

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

auth/auth.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -614,8 +614,12 @@ static unsigned int find_next_user_scheme_type(void)
614614
const unsigned int avail = user_authn_type_mask & ~user_authn_registered;
615615

616616
/* For the source of this horrible hack, see:
617-
https://graphics.stanford.edu/~seander/bithacks.html#CountBitsSetKernighan*/
618-
return avail & ~(avail & (avail - 1));
617+
https://graphics.stanford.edu/~seander/bithacks.html#CountBitsSetKernighan
618+
619+
return avail & ~(avail & (avail - 1));
620+
621+
Along comes clang and optimizes the above to just two instructions... */
622+
return avail & -avail;
619623
}
620624

621625
apr_status_t serf_authn_register_scheme(const char *name,

0 commit comments

Comments
 (0)