Skip to content

Commit

Permalink
Support to_int calls in Zlib.crc32
Browse files Browse the repository at this point in the history
And throw away all the conversion code, we have generic code to do that.
  • Loading branch information
herwinw committed Jan 26, 2025
1 parent 374abc6 commit 6505f25
Showing 1 changed file with 1 addition and 9 deletions.
10 changes: 1 addition & 9 deletions lib/zlib.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<long>::min())
env->raise("RangeError", "integer {} too small to convert to `long'", crc_temp);
else if (crc_temp > std::numeric_limits<long>::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<long>(env, args.at(1));
}
if (args.size() > 0) {
Value string = args.at(0);
Expand Down

0 comments on commit 6505f25

Please sign in to comment.