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
a2a7267c
Commit
a2a7267c
authored
Apr 22, 2016
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
avoid code duplication in utility function by using macros
parent
f93e8de1
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
10 additions
and
18 deletions
+10
-18
Cython/Utility/ModuleSetupCode.c
Cython/Utility/ModuleSetupCode.c
+5
-0
Cython/Utility/TypeConversion.c
Cython/Utility/TypeConversion.c
+5
-18
No files found.
Cython/Utility/ModuleSetupCode.c
View file @
a2a7267c
...
...
@@ -93,9 +93,13 @@
#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)
#define __Pyx_PyUnicode_WRITE(k, d, i, ch) PyUnicode_WRITE(k, d, i, ch)
#define __Pyx_PyUnicode_IS_TRUE(u) (0 != (likely(PyUnicode_IS_READY(u)) ? PyUnicode_GET_LENGTH(u) : PyUnicode_GET_SIZE(u)))
#else
#define CYTHON_PEP393_ENABLED 0
#define PyUnicode_1BYTE_KIND 1
#define PyUnicode_2BYTE_KIND 2
#define PyUnicode_4BYTE_KIND 4
#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]))
...
...
@@ -103,6 +107,7 @@
#define __Pyx_PyUnicode_DATA(u) ((void*)PyUnicode_AS_UNICODE(u))
/* (void)(k) => avoid unused variable warning due to macro: */
#define __Pyx_PyUnicode_READ(k, d, i) ((void)(k), (Py_UCS4)(((Py_UNICODE*)d)[i]))
#define __Pyx_PyUnicode_WRITE(k, d, i, ch) (((void)(k)), ((Py_UNICODE*)d)[i] = ch)
#define __Pyx_PyUnicode_IS_TRUE(u) (0 != PyUnicode_GET_SIZE(u))
#endif
...
...
Cython/Utility/TypeConversion.c
View file @
a2a7267c
...
...
@@ -653,45 +653,32 @@ static PyObject* __Pyx_PyUnicode_Build(Py_ssize_t ulength, char* chars, int clen
Py_ssize_t
uoffset
=
ulength
-
clength
;
#if CYTHON_COMPILING_IN_CPYTHON
Py_ssize_t
i
;
#if
PY_MAJOR_VERSION > 3 || PY_MAJOR_VERSION == 3 && PY_MINOR_VERSION >= 3
#if
CYTHON_PEP393_ENABLED
// Py 3.3+ (post PEP-393)
void
*
udata
;
uval
=
PyUnicode_New
(
ulength
,
127
);
if
(
unlikely
(
!
uval
))
return
NULL
;
udata
=
PyUnicode_DATA
(
uval
);
if
(
uoffset
>
0
)
{
i
=
0
;
if
(
prepend_sign
)
{
PyUnicode_WRITE
(
PyUnicode_1BYTE_KIND
,
udata
,
0
,
'-'
);
i
++
;
}
for
(;
i
<
uoffset
;
i
++
)
{
PyUnicode_WRITE
(
PyUnicode_1BYTE_KIND
,
udata
,
i
,
padding_char
);
}
}
for
(
i
=
0
;
i
<
clength
;
i
++
)
{
PyUnicode_WRITE
(
PyUnicode_1BYTE_KIND
,
udata
,
uoffset
+
i
,
chars
[
i
]);
}
#else
// Py 2.x/3.2 (pre PEP-393)
Py_UNICODE
*
udata
;
uval
=
PyUnicode_FromUnicode
(
NULL
,
ulength
);
if
(
unlikely
(
!
uval
))
return
NULL
;
udata
=
PyUnicode_AS_UNICODE
(
uval
);
#endif
if
(
uoffset
>
0
)
{
i
=
0
;
if
(
prepend_sign
)
{
udata
[
0
]
=
'-'
;
__Pyx_PyUnicode_WRITE
(
PyUnicode_1BYTE_KIND
,
udata
,
0
,
'-'
)
;
i
++
;
}
for
(;
i
<
uoffset
;
i
++
)
{
udata
[
i
]
=
padding_char
;
__Pyx_PyUnicode_WRITE
(
PyUnicode_1BYTE_KIND
,
udata
,
i
,
padding_char
)
;
}
}
for
(
i
=
0
;
i
<
clength
;
i
++
)
{
udata
[
uoffset
+
i
]
=
chars
[
i
]
;
__Pyx_PyUnicode_WRITE
(
PyUnicode_1BYTE_KIND
,
udata
,
uoffset
+
i
,
chars
[
i
])
;
}
#endif
#else
// non-CPython
...
...
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