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
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Gwenaël Samain
cython
Commits
3096eac8
Commit
3096eac8
authored
Nov 10, 2013
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
inline PyUnicode_Compare() function for equality comparisons
parent
3e6bb233
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
4 deletions
+13
-4
Cython/Utility/ModuleSetupCode.c
Cython/Utility/ModuleSetupCode.c
+4
-0
Cython/Utility/StringTools.c
Cython/Utility/StringTools.c
+9
-4
No files found.
Cython/Utility/ModuleSetupCode.c
View file @
3096eac8
...
...
@@ -143,12 +143,16 @@
0 : _PyUnicode_Ready((PyObject *)(op)))
#define __Pyx_PyUnicode_GET_LENGTH(u) PyUnicode_GET_LENGTH(u)
#define __Pyx_PyUnicode_READ_CHAR(u, i) PyUnicode_READ_CHAR(u, i)
#define __Pyx_PyUnicode_KIND(u) PyUnicode_KIND(u)
#define __Pyx_PyUnicode_DATA(u) PyUnicode_DATA(u)
#define __Pyx_PyUnicode_READ(k, d, i) PyUnicode_READ(k, d, i)
#else
#define CYTHON_PEP393_ENABLED 0
#define __Pyx_PyUnicode_READY(op) (0)
#define __Pyx_PyUnicode_GET_LENGTH(u) PyUnicode_GET_SIZE(u)
#define __Pyx_PyUnicode_READ_CHAR(u, i) ((Py_UCS4)(PyUnicode_AS_UNICODE(u)[i]))
#define __Pyx_PyUnicode_KIND(u) (sizeof(Py_UNICODE))
#define __Pyx_PyUnicode_DATA(u) ((void*)PyUnicode_AS_UNICODE(u))
/* (k=k) => avoid unused variable warning due to macro: */
#define __Pyx_PyUnicode_READ(k, d, i) ((k=k), (Py_UCS4)(((Py_UNICODE*)d)[i]))
#endif
...
...
Cython/Utility/StringTools.c
View file @
3096eac8
...
...
@@ -143,6 +143,8 @@ static CYTHON_INLINE int __Pyx_PyUnicode_Equals(PyObject* s1, PyObject* s2, int
return
(
equals
==
Py_EQ
);
}
else
if
(
PyUnicode_CheckExact
(
s1
)
&
PyUnicode_CheckExact
(
s2
))
{
Py_ssize_t
length
;
int
kind
;
void
*
data1
,
*
data2
;
#if CYTHON_PEP393_ENABLED
if
(
unlikely
(
PyUnicode_READY
(
s1
)
<
0
)
||
unlikely
(
PyUnicode_READY
(
s2
)
<
0
))
return
-
1
;
...
...
@@ -151,14 +153,17 @@ static CYTHON_INLINE int __Pyx_PyUnicode_Equals(PyObject* s1, PyObject* s2, int
if
(
length
!=
__Pyx_PyUnicode_GET_LENGTH
(
s2
))
return
(
equals
==
Py_NE
);
// len(s1) == len(s2) >= 1 (empty string is interned, and "s1 is not s2")
if
(
__Pyx_PyUnicode_READ_CHAR
(
s1
,
0
)
!=
__Pyx_PyUnicode_READ_CHAR
(
s2
,
0
))
{
kind
=
__Pyx_PyUnicode_KIND
(
s1
);
if
(
kind
!=
__Pyx_PyUnicode_KIND
(
s2
))
return
(
equals
==
Py_NE
);
data1
=
__Pyx_PyUnicode_DATA
(
s1
);
data2
=
__Pyx_PyUnicode_DATA
(
s2
);
if
(
__Pyx_PyUnicode_READ
(
kind
,
data1
,
0
)
!=
__Pyx_PyUnicode_READ
(
kind
,
data2
,
0
))
{
return
(
equals
==
Py_NE
);
}
else
if
(
length
==
1
)
{
return
(
equals
==
Py_EQ
);
}
else
{
int
result
=
PyUnicode_Compare
(
s1
,
s2
);
if
((
result
==
-
1
)
&&
unlikely
(
PyErr_Occurred
()))
return
-
1
;
int
result
=
memcmp
(
data1
,
data2
,
length
*
kind
);
return
(
equals
==
Py_EQ
)
?
(
result
==
0
)
:
(
result
!=
0
);
}
}
else
if
((
s1
==
Py_None
)
&
PyUnicode_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