1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

bignum.c: hide intermediate Bignums

* bignum.c (rb_big_eq): hide intermediate Bignums not just freeing
  memory.  [ruby-core:53893] [Bug #8204]
* object.c (rb_obj_hide): hide an object by clearing klass.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40077 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2013-04-03 07:35:35 +00:00
parent b30a6b8d1d
commit adf1c94ffe
4 changed files with 18 additions and 1 deletions

View file

@ -1,4 +1,9 @@
Wed Apr 3 16:34:24 2013 Nobuyoshi Nakada <nobu@ruby-lang.org>
Wed Apr 3 16:35:32 2013 Nobuyoshi Nakada <nobu@ruby-lang.org>
* bignum.c (rb_big_eq): hide intermediate Bignums not just freeing
memory. [ruby-core:53893] [Bug #8204]
* object.c (rb_obj_hide): hide an object by clearing klass.
* bignum.c (rb_big_eq): test as Fixnum if possible and get rid of zero
length Bignum. [ruby-core:53893] [Bug #8204]

View file

@ -1095,6 +1095,8 @@ big2str_karatsuba(VALUE x, int base, char* ptr,
b = power_cache_get_power(base, n1, &m1);
bigdivmod(x, b, &q, &r);
rb_obj_hide(q);
rb_obj_hide(r);
lh = big2str_karatsuba(q, base, ptr, (len - m1)/2,
len - m1, hbase, trim);
rb_big_resize(q, 0);

View file

@ -196,6 +196,7 @@ VALUE rb_int_pred(VALUE num);
/* object.c */
VALUE rb_obj_equal(VALUE obj1, VALUE obj2);
VALUE rb_obj_hide(VALUE obj);
/* parse.y */
VALUE rb_parser_get_yydebug(VALUE);

View file

@ -43,6 +43,15 @@ static ID id_const_missing;
(!SPECIAL_CONST_P(obj) && \
(BUILTIN_TYPE(obj) == T_CLASS || BUILTIN_TYPE(obj) == T_MODULE))
VALUE
rb_obj_hide(VALUE obj)
{
if (!SPECIAL_CONST_P(obj)) {
RBASIC(obj)->klass = 0;
}
return obj;
}
/*
* call-seq:
* obj === other -> true or false