trinity.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 4/7] simplify div by 2,4,8,16 statement
@ 2015-03-16 20:26 tyson.w.smith
  0 siblings, 0 replies; only message in thread
From: tyson.w.smith @ 2015-03-16 20:26 UTC (permalink / raw)
  To: davej; +Cc: trinity, tysmith, Tyson Smith

From: Tyson Smith <tyson.w.smith@gmail.com>

---
 random.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/random.c b/random.c
index 8b4f715..8b8de04 100644
--- a/random.c
+++ b/random.c
@@ -108,10 +108,8 @@ unsigned int rand32(void)
 		r = ~r + 1;
 
 	/* we might get lucky if something is counting ints/longs etc. */
-	if (ONE_IN(4)) {
-		int _div = 1 << RAND_RANGE(1, 4);	/* 2,4,8 or 16 */
-		r /= _div;
-	}
+	if (ONE_IN(4))
+		r /= 2 << (rand() & 3); /* 2,4,8 or 16 */
 
 	/* limit the size */
 	switch (rand() % 5) {
-- 
1.9.1

^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2015-03-16 20:26 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-03-16 20:26 [PATCH 4/7] simplify div by 2,4,8,16 statement tyson.w.smith

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).