diff --git a/vm/math.cpp b/vm/math.cpp index cc1fce796e..8b99895e39 100644 --- a/vm/math.cpp +++ b/vm/math.cpp @@ -190,24 +190,6 @@ void factor_vm::primitive_bignum_log2() { ctx->replace(tag(bignum_integer_length(untag(ctx->peek())))); } -/* Allocates memory */ -cell factor_vm::unbox_array_size_slow() { - if (tagged(ctx->peek()).type() == BIGNUM_TYPE) { - bignum* zero = untag(bignum_zero); - GC_BIGNUM(zero); - bignum* max = cell_to_bignum(array_size_max); - bignum* n = untag(ctx->peek()); - if (bignum_compare(n, zero) != bignum_comparison_less && - bignum_compare(n, max) == bignum_comparison_less) { - ctx->pop(); - return bignum_to_cell(n); - } - } - - general_error(ERROR_ARRAY_SIZE, ctx->pop(), tag_fixnum(array_size_max)); - return 0; /* can't happen */ -} - /* Allocates memory */ void factor_vm::primitive_fixnum_to_float() { ctx->replace(allot_float(fixnum_to_float(ctx->peek()))); diff --git a/vm/math.hpp b/vm/math.hpp index b39ee80b6f..04daf74d90 100644 --- a/vm/math.hpp +++ b/vm/math.hpp @@ -50,16 +50,13 @@ inline double factor_vm::fixnum_to_float(cell tagged) { } inline cell factor_vm::unbox_array_size() { - cell obj = ctx->peek(); - if (TAG(obj) == FIXNUM_TYPE) { - fixnum n = untag_fixnum(obj); - if (n >= 0 && n < (fixnum)array_size_max) { - ctx->pop(); - return n; - } + cell obj = ctx->pop(); + fixnum n = to_fixnum(obj); + if (n >= 0 && n < (fixnum)array_size_max) { + return n; } - - return unbox_array_size_slow(); + general_error(ERROR_ARRAY_SIZE, obj, tag_fixnum(array_size_max)); + return 0; /* can't happen */ } VM_C_API cell from_signed_cell(fixnum integer, factor_vm* vm);