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
7409172f
Commit
7409172f
authored
Dec 29, 2016
by
Claudio Freire
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Relocate hash check to improve worst case
parent
0ec031fa
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
7 deletions
+7
-7
Cython/Utility/StringTools.c
Cython/Utility/StringTools.c
+7
-7
No files found.
Cython/Utility/StringTools.c
View file @
7409172f
...
...
@@ -263,13 +263,6 @@ static CYTHON_INLINE int __Pyx_PyBytes_Equals(PyObject* s1, PyObject* s2, int eq
Py_ssize_t
length
=
PyBytes_GET_SIZE
(
s1
);
if
(
length
!=
PyBytes_GET_SIZE
(
s2
))
return
(
equals
==
Py_NE
);
#if CYTHON_COMPILING_IN_CPYTHON
if
(((
PyBytesObject
*
)
s1
)
->
ob_shash
!=
((
PyBytesObject
*
)
s2
)
->
ob_shash
&&
((
PyBytesObject
*
)
s1
)
->
ob_shash
!=
-
1
&&
((
PyBytesObject
*
)
s2
)
->
ob_shash
!=
-
1
)
{
return
(
equals
==
Py_NE
);
}
#endif
// len(s1) == len(s2) >= 1 (empty string is interned, and "s1 is not s2")
ps1
=
PyBytes_AS_STRING
(
s1
);
ps2
=
PyBytes_AS_STRING
(
s2
);
...
...
@@ -278,6 +271,13 @@ 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
)
{
return
(
equals
==
Py_NE
);
}
#endif
int
result
=
memcmp
(
ps1
,
ps2
,
(
size_t
)
length
);
return
(
equals
==
Py_EQ
)
?
(
result
==
0
)
:
(
result
!=
0
);
}
...
...
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