summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefan Behnel <stefan_ml@behnel.de>2020-04-20 09:49:53 +0200
committerStefan Behnel <stefan_ml@behnel.de>2020-04-20 09:49:53 +0200
commit9c121839a04e82ee9796fffd63840e1baf3bb84c (patch)
treea72e0dc120b3cd5d90597a8b1fc9a317704ef974
parent698d162b5a896134e6190532c5fed8ef56ad0fb4 (diff)
downloadcython-9c121839a04e82ee9796fffd63840e1baf3bb84c.tar.gz
Do not create a new unicode string object when taking a fully slice.
-rw-r--r--Cython/Utility/StringTools.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/Cython/Utility/StringTools.c b/Cython/Utility/StringTools.c
index bd9271117..f5691e2b1 100644
--- a/Cython/Utility/StringTools.c
+++ b/Cython/Utility/StringTools.c
@@ -613,6 +613,8 @@ static CYTHON_INLINE PyObject* __Pyx_PyUnicode_Substring(
stop = length;
if (stop <= start)
return __Pyx_NewRef($empty_unicode);
+ if (start == 0 && stop == length)
+ return __Pyx_NewRef(text);
#if CYTHON_PEP393_ENABLED
return PyUnicode_FromKindAndData(PyUnicode_KIND(text),
PyUnicode_1BYTE_DATA(text) + start*PyUnicode_KIND(text), stop-start);