From 75a99f62cd6abd0efcd560c606c5782934a7f778 Mon Sep 17 00:00:00 2001 From: Andrew Nacin Date: Sat, 13 Feb 2010 03:33:33 +0000 Subject: [PATCH] Optimize wp_rand(), only check transient when needed. Fixes #12144. git-svn-id: https://develop.svn.wordpress.org/trunk@13080 602fd350-edb4-49c9-b593-d223f7449a82 --- wp-includes/pluggable.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/wp-includes/pluggable.php b/wp-includes/pluggable.php index 5244ccad15..3dddb61695 100644 --- a/wp-includes/pluggable.php +++ b/wp-includes/pluggable.php @@ -1492,11 +1492,10 @@ if ( !function_exists('wp_rand') ) : function wp_rand( $min = 0, $max = 0 ) { global $rnd_value; - $seed = get_transient('random_seed'); - // Reset $rnd_value after 14 uses // 32(md5) + 40(sha1) + 40(sha1) / 8 = 14 random numbers from $rnd_value if ( strlen($rnd_value) < 8 ) { + $seed = get_transient('random_seed'); $rnd_value = md5( uniqid(microtime() . mt_rand(), true ) . $seed ); $rnd_value .= sha1($rnd_value); $rnd_value .= sha1($rnd_value . $seed);