Reducing the number of divisions in rb_fix_digits
This commit is contained in:
parent
2e153fd037
commit
19f4b06b9d
@ -5453,11 +5453,12 @@ rb_fix_digits(VALUE fix, long base)
|
|||||||
return rb_ary_new_from_args(1, INT2FIX(0));
|
return rb_ary_new_from_args(1, INT2FIX(0));
|
||||||
|
|
||||||
digits = rb_ary_new();
|
digits = rb_ary_new();
|
||||||
while (x > 0) {
|
while (x >= base) {
|
||||||
long q = x % base;
|
long q = x % base;
|
||||||
rb_ary_push(digits, LONG2NUM(q));
|
rb_ary_push(digits, LONG2NUM(q));
|
||||||
x /= base;
|
x /= base;
|
||||||
}
|
}
|
||||||
|
rb_ary_push(digits, LONG2NUM(x));
|
||||||
|
|
||||||
return digits;
|
return digits;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user