Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Labels
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
nexedi
cython
Commits
a955a777
Commit
a955a777
authored
Jan 02, 2017
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
clean up string comparison optimisation from github #1571
parent
760d0429
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
21 additions
and
19 deletions
+21
-19
Cython/Utility/StringTools.c
Cython/Utility/StringTools.c
+21
-19
No files found.
Cython/Utility/StringTools.c
View file @
a955a777
...
...
@@ -39,8 +39,8 @@ static int __Pyx_InitStrings(__Pyx_StringTabEntry *t) {
#endif
if
(
!*
t
->
p
)
return
-
1
;
hash
=
PyObject_Hash
(
*
t
->
p
);
if
(
hash
==
-
1
)
// initialise cached hash value
if
(
PyObject_Hash
(
*
t
->
p
)
==
-
1
)
PyErr_Clear
();
++
t
;
}
...
...
@@ -189,20 +189,20 @@ static CYTHON_INLINE int __Pyx_PyUnicode_Equals(PyObject* s1, PyObject* s2, int
if
(
length
!=
__Pyx_PyUnicode_GET_LENGTH
(
s2
))
{
goto
return_ne
;
}
#if CYTHON_COMPILING_IN_CPYTHON
#if CYTHON_PEP393_ENABLED
if
(((
PyASCIIObject
*
)
s1
)
->
hash
!=
((
PyASCIIObject
*
)
s2
)
->
hash
&&
((
PyASCIIObject
*
)
s1
)
->
hash
!=
-
1
&&
((
PyASCIIObject
*
)
s2
)
->
hash
!=
-
1
)
{
goto
return_ne
;
}
#else
if
(((
PyUnicodeObject
*
)
s1
)
->
hash
!=
((
PyUnicodeObject
*
)
s2
)
->
hash
&&
((
PyUnicodeObject
*
)
s1
)
->
hash
!=
-
1
&&
((
PyUnicodeObject
*
)
s2
)
->
hash
!=
-
1
)
#if CYTHON_USE_UNICODE_INTERNALS
{
goto
return_ne
;
Py_hash_t
hash1
,
hash2
;
#if CYTHON_PEP393_ENABLED
hash1
=
((
PyASCIIObject
*
)
s1
)
->
hash
;
hash2
=
((
PyASCIIObject
*
)
s2
)
->
hash
;
#else
hash1
=
((
PyUnicodeObject
*
)
s1
)
->
hash
;
hash2
=
((
PyUnicodeObject
*
)
s2
)
->
hash
;
#endif
if
(
hash1
!=
hash2
&&
hash1
!=
-
1
&&
hash2
!=
-
1
)
{
goto
return_ne
;
}
}
#endif
#endif
// len(s1) == len(s2) >= 1 (empty string is interned, and "s1 is not s2")
kind
=
__Pyx_PyUnicode_KIND
(
s1
);
...
...
@@ -276,14 +276,16 @@ static CYTHON_INLINE int __Pyx_PyBytes_Equals(PyObject* s1, PyObject* s2, int eq
}
else
if
(
length
==
1
)
{
return
(
equals
==
Py_EQ
);
}
else
{
#if CYTHON_COMPILING_IN_CPYTHON
if
(((
PyBytesObject
*
)
s1
)
->
ob_shash
!=
((
PyBytesObject
*
)
s2
)
->
ob_shash
&&
((
PyBytesObject
*
)
s1
)
->
ob_shash
!=
-
1
&&
((
PyBytesObject
*
)
s2
)
->
ob_shash
!=
-
1
)
{
int
result
;
#if CYTHON_USE_UNICODE_INTERNALS
Py_hash_t
hash1
,
hash2
;
hash1
=
((
PyBytesObject
*
)
s1
)
->
ob_shash
;
hash2
=
((
PyBytesObject
*
)
s2
)
->
ob_shash
;
if
(
hash1
!=
hash2
&&
hash1
!=
-
1
&&
hash2
!=
-
1
)
{
return
(
equals
==
Py_NE
);
}
#endif
int
result
=
memcmp
(
ps1
,
ps2
,
(
size_t
)
length
);
result
=
memcmp
(
ps1
,
ps2
,
(
size_t
)
length
);
return
(
equals
==
Py_EQ
)
?
(
result
==
0
)
:
(
result
!=
0
);
}
}
else
if
((
s1
==
Py_None
)
&
PyBytes_CheckExact
(
s2
))
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment