[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Tyson Smith <tysmith@xxxxxxxxxxxx>

Since rand_bool is used a heavily used operation simplifying it may
shave off some cycles here and there. Also replaced %2 with &1 with the
same intention.
---
 include/random.h | 3 ++-
 random.c         | 5 -----
 2 files changed, 2 insertions(+), 6 deletions(-)

diff --git a/include/random.h b/include/random.h
index 69ccfa3..b8f8d2c 100644
--- a/include/random.h
+++ b/include/random.h
@@ -13,6 +13,8 @@
 #error "Unexpected RAND_MAX value. Please add support."
 #endif
 
+#define rand_bool()				(rand() & 1)
+
 extern unsigned int seed;
 unsigned int init_seed(unsigned int seed);
 void set_seed(struct childdata *child);
@@ -20,7 +22,6 @@ void reseed(void);
 unsigned int new_seed(void);
 
 void generate_rand_bytes(unsigned char *ptr, unsigned int len);
-unsigned int rand_bool(void);
 unsigned int rand32(void);
 u64 rand64(void);
 unsigned int rand_range(unsigned int min, unsigned int max);
diff --git a/random.c b/random.c
index 063912f..a1ff7a8 100644
--- a/random.c
+++ b/random.c
@@ -64,11 +64,6 @@ unsigned long set_rand_bitmask(unsigned int num, const unsigned long *values)
 	return mask;
 }
 
-unsigned int rand_bool(void)
-{
-	return rand() % 2;
-}
-
 /*
  * Pick a random power of two between 2^0 and 2^(__WORDSIZE-1)
  */
-- 
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe trinity" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux SCSI]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux