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
f5bfa123
Commit
f5bfa123
authored
Aug 23, 2012
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
cleanups and portability fixes in optimised string methods
parent
550a70ed
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
22 additions
and
8 deletions
+22
-8
Cython/Utility/Optimize.c
Cython/Utility/Optimize.c
+22
-8
No files found.
Cython/Utility/Optimize.c
View file @
f5bfa123
...
@@ -119,11 +119,18 @@ static CYTHON_INLINE int __Pyx_Py_UNICODE_ISTITLE(Py_UCS4 uchar)
...
@@ -119,11 +119,18 @@ static CYTHON_INLINE int __Pyx_Py_UNICODE_ISTITLE(Py_UCS4 uchar)
static
int
__Pyx_PyUnicode_Tailmatch
(
PyObject
*
s
,
PyObject
*
substr
,
static
int
__Pyx_PyUnicode_Tailmatch
(
PyObject
*
s
,
PyObject
*
substr
,
Py_ssize_t
start
,
Py_ssize_t
end
,
int
direction
)
{
Py_ssize_t
start
,
Py_ssize_t
end
,
int
direction
)
{
if
(
unlikely
(
PyTuple_Check
(
substr
)))
{
if
(
unlikely
(
PyTuple_Check
(
substr
)))
{
int
result
;
Py_ssize_t
i
,
count
=
PyTuple_GET_SIZE
(
substr
);
Py_ssize_t
i
;
for
(
i
=
0
;
i
<
count
;
i
++
)
{
for
(
i
=
0
;
i
<
PyTuple_GET_SIZE
(
substr
);
i
++
)
{
int
result
;
#if CYTHON_COMPILING_IN_CPYTHON
result
=
PyUnicode_Tailmatch
(
s
,
PyTuple_GET_ITEM
(
substr
,
i
),
result
=
PyUnicode_Tailmatch
(
s
,
PyTuple_GET_ITEM
(
substr
,
i
),
start
,
end
,
direction
);
start
,
end
,
direction
);
#else
PyObject
*
sub
=
PySequence_GetItem
(
substr
,
i
);
if
(
unlikely
(
!
sub
))
return
-
1
;
result
=
PyUnicode_Tailmatch
(
s
,
sub
,
start
,
end
,
direction
);
Py_DECREF
(
sub
);
#endif
if
(
result
)
{
if
(
result
)
{
return
result
;
return
result
;
}
}
...
@@ -206,11 +213,18 @@ static int __Pyx_PyBytes_Tailmatch(PyObject* self, PyObject* substr, Py_ssize_t
...
@@ -206,11 +213,18 @@ static int __Pyx_PyBytes_Tailmatch(PyObject* self, PyObject* substr, Py_ssize_t
Py_ssize_t
end
,
int
direction
)
Py_ssize_t
end
,
int
direction
)
{
{
if
(
unlikely
(
PyTuple_Check
(
substr
)))
{
if
(
unlikely
(
PyTuple_Check
(
substr
)))
{
int
result
;
Py_ssize_t
i
,
count
=
PyTuple_GET_SIZE
(
substr
);
Py_ssize_t
i
;
for
(
i
=
0
;
i
<
count
;
i
++
)
{
for
(
i
=
0
;
i
<
PyTuple_GET_SIZE
(
substr
);
i
++
)
{
int
result
;
#if CYTHON_COMPILING_IN_CPYTHON
result
=
__Pyx_PyBytes_SingleTailmatch
(
self
,
PyTuple_GET_ITEM
(
substr
,
i
),
result
=
__Pyx_PyBytes_SingleTailmatch
(
self
,
PyTuple_GET_ITEM
(
substr
,
i
),
start
,
end
,
direction
);
start
,
end
,
direction
);
#else
PyObject
*
sub
=
PySequence_GetItem
(
substr
,
i
);
if
(
unlikely
(
!
sub
))
return
-
1
;
result
=
__Pyx_PyBytes_SingleTailmatch
(
s
,
sub
,
start
,
end
,
direction
);
Py_DECREF
(
sub
);
#endif
if
(
result
)
{
if
(
result
)
{
return
result
;
return
result
;
}
}
...
@@ -226,8 +240,8 @@ static int __Pyx_PyBytes_Tailmatch(PyObject* self, PyObject* substr, Py_ssize_t
...
@@ -226,8 +240,8 @@ static int __Pyx_PyBytes_Tailmatch(PyObject* self, PyObject* substr, Py_ssize_t
static
CYTHON_INLINE
char
__Pyx_PyBytes_GetItemInt
(
PyObject
*
bytes
,
Py_ssize_t
index
,
int
check_bounds
)
{
static
CYTHON_INLINE
char
__Pyx_PyBytes_GetItemInt
(
PyObject
*
bytes
,
Py_ssize_t
index
,
int
check_bounds
)
{
if
(
check_bounds
)
{
if
(
check_bounds
)
{
if
(
unlikely
(
index
>=
PyBytes_GET_SIZE
(
bytes
))
|
Py_ssize_t
size
=
PyBytes_GET_SIZE
(
bytes
);
((
index
<
0
)
&
unlikely
(
index
<
-
PyBytes_GET_SIZE
(
bytes
)
)))
{
if
(
unlikely
(
index
>=
size
)
|
((
index
<
0
)
&
unlikely
(
index
<
-
size
)))
{
PyErr_Format
(
PyExc_IndexError
,
"string index out of range"
);
PyErr_Format
(
PyExc_IndexError
,
"string index out of range"
);
return
-
1
;
return
-
1
;
}
}
...
...
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