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

Use & instead of modulo

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66830 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2019-01-15 12:05:46 +00:00
parent d154bec0d5
commit d7976d1451
2 changed files with 6 additions and 6 deletions

View file

@ -810,11 +810,11 @@ strio_ungetbyte(VALUE self, VALUE c)
return Qnil; return Qnil;
case T_FIXNUM: case T_FIXNUM:
case T_BIGNUM: ; case T_BIGNUM: ;
/* rb_int_modulo() not visible from exts */ /* rb_int_and() not visible from exts */
VALUE v = rb_funcall(c, rb_intern("modulo"), 1, INT2FIX(256)); VALUE v = rb_funcall(c, '&', 1, INT2FIX(0xff));
unsigned char cc = NUM2INT(v) & 0xFF; const char cc = NUM2INT(v) & 0xFF;
c = rb_str_new((const char *)&cc, 1); strio_unget_bytes(ptr, &cc, 1);
break; return Qnil;
default: default:
SafeStringValue(c); SafeStringValue(c);
} }

View file

@ -5421,7 +5421,7 @@ rb_str_setbyte(VALUE str, VALUE index, VALUE value)
pos += len; pos += len;
VALUE v = rb_to_int(value); VALUE v = rb_to_int(value);
VALUE w = rb_int_modulo(v, INT2FIX(256)); VALUE w = rb_int_and(v, INT2FIX(0xff));
unsigned char byte = NUM2INT(w) & 0xFF; unsigned char byte = NUM2INT(w) & 0xFF;
if (!str_independent(str)) if (!str_independent(str))