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
Kirill Smelkov
cython
Commits
502394e7
Commit
502394e7
authored
Jan 06, 2013
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
safety fixes and a little branch prediction helping in CyFunction utility code
parent
496d3224
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
25 additions
and
21 deletions
+25
-21
Cython/Utility/CythonFunction.c
Cython/Utility/CythonFunction.c
+25
-21
No files found.
Cython/Utility/CythonFunction.c
View file @
502394e7
...
@@ -65,16 +65,19 @@ static int __Pyx_CyFunction_init(void);
...
@@ -65,16 +65,19 @@ static int __Pyx_CyFunction_init(void);
static
PyObject
*
static
PyObject
*
__Pyx_CyFunction_get_doc
(
__pyx_CyFunctionObject
*
op
,
CYTHON_UNUSED
void
*
closure
)
__Pyx_CyFunction_get_doc
(
__pyx_CyFunctionObject
*
op
,
CYTHON_UNUSED
void
*
closure
)
{
{
if
(
op
->
func_doc
==
NULL
&&
op
->
func
.
m_ml
->
ml_doc
)
{
if
(
unlikely
(
op
->
func_doc
==
NULL
))
{
if
(
op
->
func
.
m_ml
->
ml_doc
)
{
#if PY_MAJOR_VERSION >= 3
#if PY_MAJOR_VERSION >= 3
op
->
func_doc
=
PyUnicode_FromString
(
op
->
func
.
m_ml
->
ml_doc
);
op
->
func_doc
=
PyUnicode_FromString
(
op
->
func
.
m_ml
->
ml_doc
);
#else
#else
op
->
func_doc
=
PyString_FromString
(
op
->
func
.
m_ml
->
ml_doc
);
op
->
func_doc
=
PyString_FromString
(
op
->
func
.
m_ml
->
ml_doc
);
#endif
#endif
}
if
(
unlikely
(
op
->
func_doc
==
NULL
))
if
(
op
->
func_doc
==
0
)
{
return
NULL
;
Py_INCREF
(
Py_None
);
}
else
{
return
Py_None
;
Py_INCREF
(
Py_None
);
return
Py_None
;
}
}
}
Py_INCREF
(
op
->
func_doc
);
Py_INCREF
(
op
->
func_doc
);
return
op
->
func_doc
;
return
op
->
func_doc
;
...
@@ -85,10 +88,9 @@ __Pyx_CyFunction_set_doc(__pyx_CyFunctionObject *op, PyObject *value)
...
@@ -85,10 +88,9 @@ __Pyx_CyFunction_set_doc(__pyx_CyFunctionObject *op, PyObject *value)
{
{
PyObject
*
tmp
=
op
->
func_doc
;
PyObject
*
tmp
=
op
->
func_doc
;
if
(
value
==
NULL
)
if
(
value
==
NULL
)
op
->
func_doc
=
Py_None
;
/* Mark as deleted */
value
=
Py_None
;
/* Mark as deleted */
else
Py_INCREF
(
value
);
op
->
func_doc
=
value
;
op
->
func_doc
=
value
;
Py_INCREF
(
op
->
func_doc
);
Py_XDECREF
(
tmp
);
Py_XDECREF
(
tmp
);
return
0
;
return
0
;
}
}
...
@@ -96,12 +98,14 @@ __Pyx_CyFunction_set_doc(__pyx_CyFunctionObject *op, PyObject *value)
...
@@ -96,12 +98,14 @@ __Pyx_CyFunction_set_doc(__pyx_CyFunctionObject *op, PyObject *value)
static
PyObject
*
static
PyObject
*
__Pyx_CyFunction_get_name
(
__pyx_CyFunctionObject
*
op
)
__Pyx_CyFunction_get_name
(
__pyx_CyFunctionObject
*
op
)
{
{
if
(
op
->
func_name
==
NULL
)
{
if
(
unlikely
(
op
->
func_name
==
NULL
)
)
{
#if PY_MAJOR_VERSION >= 3
#if PY_MAJOR_VERSION >= 3
op
->
func_name
=
PyUnicode_InternFromString
(
op
->
func
.
m_ml
->
ml_name
);
op
->
func_name
=
PyUnicode_InternFromString
(
op
->
func
.
m_ml
->
ml_name
);
#else
#else
op
->
func_name
=
PyString_InternFromString
(
op
->
func
.
m_ml
->
ml_name
);
op
->
func_name
=
PyString_InternFromString
(
op
->
func
.
m_ml
->
ml_name
);
#endif
#endif
if
(
unlikely
(
op
->
func_name
==
NULL
))
return
NULL
;
}
}
Py_INCREF
(
op
->
func_name
);
Py_INCREF
(
op
->
func_name
);
return
op
->
func_name
;
return
op
->
func_name
;
...
@@ -113,9 +117,9 @@ __Pyx_CyFunction_set_name(__pyx_CyFunctionObject *op, PyObject *value)
...
@@ -113,9 +117,9 @@ __Pyx_CyFunction_set_name(__pyx_CyFunctionObject *op, PyObject *value)
PyObject
*
tmp
;
PyObject
*
tmp
;
#if PY_MAJOR_VERSION >= 3
#if PY_MAJOR_VERSION >= 3
if
(
value
==
NULL
||
!
PyUnicode_Check
(
value
))
{
if
(
unlikely
(
value
==
NULL
||
!
PyUnicode_Check
(
value
)
))
{
#else
#else
if
(
value
==
NULL
||
!
PyString_Check
(
value
))
{
if
(
unlikely
(
value
==
NULL
||
!
PyString_Check
(
value
)
))
{
#endif
#endif
PyErr_SetString
(
PyExc_TypeError
,
PyErr_SetString
(
PyExc_TypeError
,
"__name__ must be set to a string object"
);
"__name__ must be set to a string object"
);
...
@@ -141,9 +145,9 @@ __Pyx_CyFunction_set_qualname(__pyx_CyFunctionObject *op, PyObject *value)
...
@@ -141,9 +145,9 @@ __Pyx_CyFunction_set_qualname(__pyx_CyFunctionObject *op, PyObject *value)
PyObject
*
tmp
;
PyObject
*
tmp
;
#if PY_MAJOR_VERSION >= 3
#if PY_MAJOR_VERSION >= 3
if
(
value
==
NULL
||
!
PyUnicode_Check
(
value
))
{
if
(
unlikely
(
value
==
NULL
||
!
PyUnicode_Check
(
value
)
))
{
#else
#else
if
(
value
==
NULL
||
!
PyString_Check
(
value
))
{
if
(
unlikely
(
value
==
NULL
||
!
PyString_Check
(
value
)
))
{
#endif
#endif
PyErr_SetString
(
PyExc_TypeError
,
PyErr_SetString
(
PyExc_TypeError
,
"__qualname__ must be set to a string object"
);
"__qualname__ must be set to a string object"
);
...
@@ -171,9 +175,9 @@ __Pyx_CyFunction_get_self(__pyx_CyFunctionObject *m, CYTHON_UNUSED void *closure
...
@@ -171,9 +175,9 @@ __Pyx_CyFunction_get_self(__pyx_CyFunctionObject *m, CYTHON_UNUSED void *closure
static
PyObject
*
static
PyObject
*
__Pyx_CyFunction_get_dict
(
__pyx_CyFunctionObject
*
op
)
__Pyx_CyFunction_get_dict
(
__pyx_CyFunctionObject
*
op
)
{
{
if
(
op
->
func_dict
==
NULL
)
{
if
(
unlikely
(
op
->
func_dict
==
NULL
)
)
{
op
->
func_dict
=
PyDict_New
();
op
->
func_dict
=
PyDict_New
();
if
(
op
->
func_dict
==
NULL
)
if
(
unlikely
(
op
->
func_dict
==
NULL
)
)
return
NULL
;
return
NULL
;
}
}
Py_INCREF
(
op
->
func_dict
);
Py_INCREF
(
op
->
func_dict
);
...
@@ -185,12 +189,12 @@ __Pyx_CyFunction_set_dict(__pyx_CyFunctionObject *op, PyObject *value)
...
@@ -185,12 +189,12 @@ __Pyx_CyFunction_set_dict(__pyx_CyFunctionObject *op, PyObject *value)
{
{
PyObject
*
tmp
;
PyObject
*
tmp
;
if
(
value
==
NULL
)
{
if
(
unlikely
(
value
==
NULL
)
)
{
PyErr_SetString
(
PyExc_TypeError
,
PyErr_SetString
(
PyExc_TypeError
,
"function's dictionary may not be deleted"
);
"function's dictionary may not be deleted"
);
return
-
1
;
return
-
1
;
}
}
if
(
!
PyDict_Check
(
value
))
{
if
(
unlikely
(
!
PyDict_Check
(
value
)
))
{
PyErr_SetString
(
PyExc_TypeError
,
PyErr_SetString
(
PyExc_TypeError
,
"setting function's dictionary to a non-dict"
);
"setting function's dictionary to a non-dict"
);
return
-
1
;
return
-
1
;
...
@@ -243,7 +247,7 @@ __Pyx_CyFunction_get_defaults(__pyx_CyFunctionObject *op)
...
@@ -243,7 +247,7 @@ __Pyx_CyFunction_get_defaults(__pyx_CyFunctionObject *op)
PyObject
*
res
=
op
->
defaults_getter
((
PyObject
*
)
op
);
PyObject
*
res
=
op
->
defaults_getter
((
PyObject
*
)
op
);
/* Cache result */
/* Cache result */
if
(
res
)
{
if
(
likely
(
res
)
)
{
Py_INCREF
(
res
);
Py_INCREF
(
res
);
op
->
defaults_tuple
=
res
;
op
->
defaults_tuple
=
res
;
}
}
...
...
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