Reducing the number of divisions in rb_fix_digits

This commit is contained in:
Reznov 2024-04-08 06:51:32 +03:00 committed by GitHub
parent 2e153fd037
commit 19f4b06b9d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -5453,11 +5453,12 @@ rb_fix_digits(VALUE fix, long base)
return rb_ary_new_from_args(1, INT2FIX(0));
digits = rb_ary_new();
while (x > 0) {
while (x >= base) {
long q = x % base;
rb_ary_push(digits, LONG2NUM(q));
x /= base;
}
rb_ary_push(digits, LONG2NUM(x));
return digits;
}