From 6505f25f92883b78ec82d31119c942602e17d7d2 Mon Sep 17 00:00:00 2001 From: Herwin Date: Sun, 26 Jan 2025 09:17:21 +0100 Subject: [PATCH] Support to_int calls in Zlib.crc32 And throw away all the conversion code, we have generic code to do that. --- lib/zlib.cpp | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/lib/zlib.cpp b/lib/zlib.cpp index cc8769e90..01b4f1637 100644 --- a/lib/zlib.cpp +++ b/lib/zlib.cpp @@ -310,15 +310,7 @@ Value Zlib_crc32(Env *env, Value self, Args &&args, Block *) { if (args.size() < 2) { crc = crc32(0L, Z_NULL, 0); } else { - auto initcrcval = args.at(1); - initcrcval->assert_type(env, Object::Type::Integer, "Integer"); - auto crc_temp = IntegerObject::convert_to_nat_int_t(env, initcrcval); - if (crc_temp < std::numeric_limits::min()) - env->raise("RangeError", "integer {} too small to convert to `long'", crc_temp); - else if (crc_temp > std::numeric_limits::max()) - env->raise("RangeError", "integer {} too big to convert to 'long'", crc_temp); - crc = (unsigned long)(crc_temp); - // crc = IntegerObject::convert_to_ulong(env, initcrcval); + crc = IntegerObject::convert_to_native_type(env, args.at(1)); } if (args.size() > 0) { Value string = args.at(0);