Skip to content

Commit 39e4481

Browse files
committed
Simplify hash type name getters
Replace PyUnicode_FromStringAndSize(name, strlen(name)) with PyUnicode_FromString(name) in the four get_name implementations, and drop the now-unused <string.h> include.
1 parent 8b83ba2 commit 39e4481

1 file changed

Lines changed: 4 additions & 5 deletions

File tree

src/_xxhash.c

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@
2828
non-cryptographic hash algorithm */
2929

3030
#include <Python.h>
31-
#include <string.h>
3231

3332
#include "xxhash.h"
3433

@@ -1005,7 +1004,7 @@ PYXXH32_get_digest_size(PYXXH32Object *self, void *closure)
10051004
static PyObject *
10061005
PYXXH32_get_name(PYXXH32Object *self, void *closure)
10071006
{
1008-
return PyUnicode_FromStringAndSize("XXH32", strlen("XXH32"));
1007+
return PyUnicode_FromString("XXH32");
10091008
}
10101009

10111010
static PyObject *
@@ -1356,7 +1355,7 @@ PYXXH64_get_digest_size(PYXXH64Object *self, void *closure)
13561355
static PyObject *
13571356
PYXXH64_get_name(PYXXH64Object *self, void *closure)
13581357
{
1359-
return PyUnicode_FromStringAndSize("XXH64", strlen("XXH64"));
1358+
return PyUnicode_FromString("XXH64");
13601359
}
13611360

13621361
static PyObject *
@@ -1714,7 +1713,7 @@ PYXXH3_64_get_digest_size(PYXXH3_64Object *self, void *closure)
17141713
static PyObject *
17151714
PYXXH3_64_get_name(PYXXH3_64Object *self, void *closure)
17161715
{
1717-
return PyUnicode_FromStringAndSize("XXH3_64", strlen("XXH3_64"));
1716+
return PyUnicode_FromString("XXH3_64");
17181717
}
17191718

17201719
static PyObject *
@@ -2091,7 +2090,7 @@ PYXXH3_128_get_digest_size(PYXXH3_128Object *self, void *closure)
20912090
static PyObject *
20922091
PYXXH3_128_get_name(PYXXH3_128Object *self, void *closure)
20932092
{
2094-
return PyUnicode_FromStringAndSize("XXH3_128", strlen("XXH3_128"));
2093+
return PyUnicode_FromString("XXH3_128");
20952094
}
20962095

20972096
static PyObject *

0 commit comments

Comments
 (0)