зеркало из https://github.com/github/ruby.git
* random.c (rb_genrand_ulong_limited): renamed from
rb_rand_internal and now this is public API. * include/ruby/ruby.h (rb_genrand_ulong_limited): added. * bignum.c (big_sparse_p): use rb_genrand_ulong_limited. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@29212 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
Родитель
7c73db266a
Коммит
493f721854
|
@ -1,3 +1,12 @@
|
|||
Fri Sep 10 10:33:18 2010 NARUSE, Yui <naruse@ruby-lang.org>
|
||||
|
||||
* random.c (rb_genrand_ulong_limited): renamed from
|
||||
rb_rand_internal and now this is public API.
|
||||
|
||||
* include/ruby/ruby.h (rb_genrand_ulong_limited): added.
|
||||
|
||||
* bignum.c (big_sparse_p): use rb_genrand_ulong_limited.
|
||||
|
||||
Fri Sep 10 13:07:22 2010 NAKAMURA, Hiroshi <nahi@ruby-lang.org>
|
||||
|
||||
* ext/digest/lib/digest.rb: removed unused exception variable
|
||||
|
|
7
bignum.c
7
bignum.c
|
@ -2214,11 +2214,10 @@ static inline VALUE
|
|||
big_sparse_p(VALUE x)
|
||||
{
|
||||
long c = 0, n = RBIGNUM_LEN(x);
|
||||
unsigned long rb_rand_internal(unsigned long i);
|
||||
|
||||
if ( BDIGITS(x)[rb_rand_internal(n / 2) + n / 4]) c++;
|
||||
if (c <= 1 && BDIGITS(x)[rb_rand_internal(n / 2) + n / 4]) c++;
|
||||
if (c <= 1 && BDIGITS(x)[rb_rand_internal(n / 2) + n / 4]) c++;
|
||||
if ( BDIGITS(x)[rb_genrand_ulong_limited(n / 2) + n / 4]) c++;
|
||||
if (c <= 1 && BDIGITS(x)[rb_genrand_ulong_limited(n / 2) + n / 4]) c++;
|
||||
if (c <= 1 && BDIGITS(x)[rb_genrand_ulong_limited(n / 2) + n / 4]) c++;
|
||||
|
||||
return (c <= 1) ? Qtrue : Qfalse;
|
||||
}
|
||||
|
|
|
@ -559,6 +559,7 @@ VALUE rb_random_bytes(VALUE rnd, long n);
|
|||
VALUE rb_random_int(VALUE rnd, VALUE max);
|
||||
unsigned int rb_random_int32(VALUE rnd);
|
||||
double rb_random_real(VALUE rnd);
|
||||
unsigned long rb_genrand_ulong_limited(unsigned long i);
|
||||
/* re.c */
|
||||
#define rb_memcmp memcmp
|
||||
int rb_memcicmp(const void*,const void*,long);
|
||||
|
|
11
random.c
11
random.c
|
@ -875,11 +875,16 @@ limited_big_rand(struct MT *mt, struct RBignum *limit)
|
|||
return rb_big_norm((VALUE)val);
|
||||
}
|
||||
|
||||
/*
|
||||
* Returns random unsigned long value in [0, _limit_].
|
||||
*
|
||||
* Note that _limit_ is included, and the range of the argument and the
|
||||
* return value depends on environments.
|
||||
*/
|
||||
unsigned long
|
||||
rb_rand_internal(unsigned long i)
|
||||
rb_genrand_ulong_limited(unsigned long limit)
|
||||
{
|
||||
struct MT *mt = default_mt();
|
||||
return limited_rand(mt, i);
|
||||
return limited_rand(default_mt(), limit);
|
||||
}
|
||||
|
||||
unsigned int
|
||||
|
|
Загрузка…
Ссылка в новой задаче