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
e9376a99
Commit
e9376a99
authored
Sep 12, 2017
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Split UnicodeContains helper to reduce inlined code.
parent
c6a6b3c9
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
32 additions
and
25 deletions
+32
-25
Cython/Utility/StringTools.c
Cython/Utility/StringTools.c
+32
-25
No files found.
Cython/Utility/StringTools.c
View file @
e9376a99
...
@@ -63,10 +63,31 @@ static CYTHON_INLINE int __Pyx_BytesContains(PyObject* bytes, char character) {
...
@@ -63,10 +63,31 @@ static CYTHON_INLINE int __Pyx_BytesContains(PyObject* bytes, char character) {
//////////////////// PyUCS4InUnicode.proto ////////////////////
//////////////////// PyUCS4InUnicode.proto ////////////////////
static
CYTHON_INLINE
int
__Pyx_UnicodeContainsUCS4
(
PyObject
*
unicode
,
Py_UCS4
character
);
/*proto*/
static
CYTHON_INLINE
int
__Pyx_UnicodeContainsUCS4
(
PyObject
*
unicode
,
Py_UCS4
character
);
/*proto*/
static
CYTHON_INLINE
int
__Pyx_PyUnicodeBufferContainsUCS4
(
Py_UNICODE
*
buffer
,
Py_ssize_t
length
,
Py_UCS4
character
);
/*proto*/
//////////////////// PyUCS4InUnicode ////////////////////
//////////////////// PyUCS4InUnicode ////////////////////
static
int
__Pyx_PyUnicodeBufferContainsUCS4_SP
(
Py_UNICODE
*
buffer
,
Py_ssize_t
length
,
Py_UCS4
character
)
{
/* handle surrogate pairs for Py_UNICODE buffers in 16bit Unicode builds */
Py_UNICODE
high_val
,
low_val
;
Py_UNICODE
*
pos
;
high_val
=
(
Py_UNICODE
)
(
0xD800
|
(((
character
-
0x10000
)
>>
10
)
&
((
1
<<
10
)
-
1
)));
low_val
=
(
Py_UNICODE
)
(
0xDC00
|
(
(
character
-
0x10000
)
&
((
1
<<
10
)
-
1
)));
for
(
pos
=
buffer
;
pos
<
buffer
+
length
-
1
;
pos
++
)
{
if
(
unlikely
((
high_val
==
pos
[
0
])
&
(
low_val
==
pos
[
1
])))
return
1
;
}
return
0
;
}
static
int
__Pyx_PyUnicodeBufferContainsUCS4_BMP
(
Py_UNICODE
*
buffer
,
Py_ssize_t
length
,
Py_UCS4
character
)
{
Py_UNICODE
uchar
;
Py_UNICODE
*
pos
;
uchar
=
(
Py_UNICODE
)
character
;
for
(
pos
=
buffer
;
pos
<
buffer
+
length
;
pos
++
)
{
if
(
unlikely
(
uchar
==
pos
[
0
]))
return
1
;
}
return
0
;
}
static
CYTHON_INLINE
int
__Pyx_UnicodeContainsUCS4
(
PyObject
*
unicode
,
Py_UCS4
character
)
{
static
CYTHON_INLINE
int
__Pyx_UnicodeContainsUCS4
(
PyObject
*
unicode
,
Py_UCS4
character
)
{
#if CYTHON_PEP393_ENABLED
#if CYTHON_PEP393_ENABLED
const
int
kind
=
PyUnicode_KIND
(
unicode
);
const
int
kind
=
PyUnicode_KIND
(
unicode
);
...
@@ -80,32 +101,18 @@ static CYTHON_INLINE int __Pyx_UnicodeContainsUCS4(PyObject* unicode, Py_UCS4 ch
...
@@ -80,32 +101,18 @@ static CYTHON_INLINE int __Pyx_UnicodeContainsUCS4(PyObject* unicode, Py_UCS4 ch
return
0
;
return
0
;
}
}
#endif
#endif
return
__Pyx_PyUnicodeBufferContainsUCS4
(
if
(
Py_UNICODE_SIZE
==
2
&&
unlikely
(
character
>
65535
))
{
PyUnicode_AS_UNICODE
(
unicode
),
return
__Pyx_PyUnicodeBufferContainsUCS4_SP
(
PyUnicode_GET_SIZE
(
unicode
),
PyUnicode_AS_UNICODE
(
unicode
),
character
);
PyUnicode_GET_SIZE
(
unicode
),
}
character
);
}
else
{
return
__Pyx_PyUnicodeBufferContainsUCS4_BMP
(
PyUnicode_AS_UNICODE
(
unicode
),
PyUnicode_GET_SIZE
(
unicode
),
character
);
static
CYTHON_INLINE
int
__Pyx_PyUnicodeBufferContainsUCS4
(
Py_UNICODE
*
buffer
,
Py_ssize_t
length
,
Py_UCS4
character
)
{
Py_UNICODE
uchar
;
Py_UNICODE
*
pos
;
#if Py_UNICODE_SIZE == 2
if
(
character
>
65535
)
{
/* handle surrogate pairs for Py_UNICODE buffers in 16bit Unicode builds */
Py_UNICODE
high_val
,
low_val
;
high_val
=
(
Py_UNICODE
)
(
0xD800
|
(((
character
-
0x10000
)
>>
10
)
&
((
1
<<
10
)
-
1
)));
low_val
=
(
Py_UNICODE
)
(
0xDC00
|
(
(
character
-
0x10000
)
&
((
1
<<
10
)
-
1
)));
for
(
pos
=
buffer
;
pos
<
buffer
+
length
-
1
;
pos
++
)
{
if
(
unlikely
(
high_val
==
pos
[
0
])
&
unlikely
(
low_val
==
pos
[
1
]))
return
1
;
}
return
0
;
}
}
#endif
uchar
=
(
Py_UNICODE
)
character
;
for
(
pos
=
buffer
;
pos
<
buffer
+
length
;
pos
++
)
{
if
(
unlikely
(
uchar
==
pos
[
0
]))
return
1
;
}
return
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