summaryrefslogtreecommitdiffstats
path: root/Modules/zlibmodule.c
diff options
context:
space:
mode:
authorMa Lin <animalize@users.noreply.github.com>2022-03-19 21:42:04 (GMT)
committerGitHub <noreply@github.com>2022-03-19 21:42:04 (GMT)
commitb3f2d4c8bab52573605c96c809a1e2162eee9d7e (patch)
treed5480532a4b6540056b4adc51798a62b430e922d /Modules/zlibmodule.c
parent82e9b0bb0ac44d4942b9e01b2cdd2ca85c17e563 (diff)
downloadcpython-b3f2d4c8bab52573605c96c809a1e2162eee9d7e.zip
cpython-b3f2d4c8bab52573605c96c809a1e2162eee9d7e.tar.gz
cpython-b3f2d4c8bab52573605c96c809a1e2162eee9d7e.tar.bz2
bpo-47040: improve document of checksum functions (gh-31955)
Clarifies a versionchanged note on crc32 & adler32 docs that the workaround is only needed for Python 2 and earlier. Also cleans up an unnecessary intermediate variable in the implementation. Authored-By: Ma Lin / animalize Co-authored-by: Gregory P. Smith <greg@krypto.org>
Diffstat (limited to 'Modules/zlibmodule.c')
-rw-r--r--Modules/zlibmodule.c8
1 files changed, 3 insertions, 5 deletions
diff --git a/Modules/zlibmodule.c b/Modules/zlibmodule.c
index f964656..4cf1b6e 100644
--- a/Modules/zlibmodule.c
+++ b/Modules/zlibmodule.c
@@ -1436,8 +1436,6 @@ static PyObject *
zlib_crc32_impl(PyObject *module, Py_buffer *data, unsigned int value)
/*[clinic end generated code: output=63499fa20af7ea25 input=26c3ed430fa00b4c]*/
{
- int signed_val;
-
/* Releasing the GIL for very small buffers is inefficient
and may lower performance */
if (data->len > 1024*5) {
@@ -1452,12 +1450,12 @@ zlib_crc32_impl(PyObject *module, Py_buffer *data, unsigned int value)
buf += (size_t) UINT_MAX;
len -= (size_t) UINT_MAX;
}
- signed_val = crc32(value, buf, (unsigned int)len);
+ value = crc32(value, buf, (unsigned int)len);
Py_END_ALLOW_THREADS
} else {
- signed_val = crc32(value, data->buf, (unsigned int)data->len);
+ value = crc32(value, data->buf, (unsigned int)data->len);
}
- return PyLong_FromUnsignedLong(signed_val & 0xffffffffU);
+ return PyLong_FromUnsignedLong(value & 0xffffffffU);
}