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
b16c07dc
Commit
b16c07dc
authored
Dec 17, 2017
by
Antoine Pitrou
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Factor out unlikely code path in set.remove() and set.discard()
parent
66221af5
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
28 additions
and
21 deletions
+28
-21
Cython/Utility/Optimize.c
Cython/Utility/Optimize.c
+28
-21
No files found.
Cython/Utility/Optimize.c
View file @
b16c07dc
...
@@ -397,19 +397,16 @@ static CYTHON_INLINE int __Pyx_dict_iter_next(
...
@@ -397,19 +397,16 @@ static CYTHON_INLINE int __Pyx_dict_iter_next(
}
}
/////////////// py_set_discard.proto ///////////////
/////////////// py_set_discard
_unhashable
.proto ///////////////
static
CYTHON_INLINE
int
__Pyx_PySet_Discard
(
PyObject
*
set
,
PyObject
*
key
);
/*proto
*/
static
int
__Pyx_PySet_DiscardUnhashable
(
PyObject
*
set
,
PyObject
*
key
);
/* proto
*/
/////////////// py_set_discard ///////////////
/////////////// py_set_discard
_unhashable
///////////////
static
CYTHON_INLINE
int
__Pyx_PySet_Discard
(
PyObject
*
set
,
PyObject
*
key
)
{
static
int
__Pyx_PySet_DiscardUnhashable
(
PyObject
*
set
,
PyObject
*
key
)
{
PyObject
*
tmpkey
;
PyObject
*
tmpkey
;
int
rv
;
int
rv
;
rv
=
PySet_Discard
(
set
,
key
);
/* Convert *key* to frozenset if necessary */
if
(
rv
<
0
)
{
if
(
!
PySet_Check
(
key
)
||
!
PyErr_ExceptionMatches
(
PyExc_TypeError
))
if
(
!
PySet_Check
(
key
)
||
!
PyErr_ExceptionMatches
(
PyExc_TypeError
))
return
-
1
;
return
-
1
;
PyErr_Clear
();
PyErr_Clear
();
...
@@ -418,6 +415,24 @@ static CYTHON_INLINE int __Pyx_PySet_Discard(PyObject *set, PyObject *key) {
...
@@ -418,6 +415,24 @@ static CYTHON_INLINE int __Pyx_PySet_Discard(PyObject *set, PyObject *key) {
return
-
1
;
return
-
1
;
rv
=
PySet_Discard
(
set
,
tmpkey
);
rv
=
PySet_Discard
(
set
,
tmpkey
);
Py_DECREF
(
tmpkey
);
Py_DECREF
(
tmpkey
);
return
rv
;
}
/////////////// py_set_discard.proto ///////////////
static
CYTHON_INLINE
int
__Pyx_PySet_Discard
(
PyObject
*
set
,
PyObject
*
key
);
/*proto*/
/////////////// py_set_discard ///////////////
//@requires: py_set_discard_unhashable
static
CYTHON_INLINE
int
__Pyx_PySet_Discard
(
PyObject
*
set
,
PyObject
*
key
)
{
int
rv
;
rv
=
PySet_Discard
(
set
,
key
);
/* Convert *key* to frozenset if necessary */
if
(
unlikely
(
rv
<
0
))
{
return
__Pyx_PySet_DiscardUnhashable
(
set
,
key
);
}
}
return
rv
;
return
rv
;
}
}
...
@@ -428,23 +443,15 @@ static CYTHON_INLINE int __Pyx_PySet_Discard(PyObject *set, PyObject *key) {
...
@@ -428,23 +443,15 @@ static CYTHON_INLINE int __Pyx_PySet_Discard(PyObject *set, PyObject *key) {
static
CYTHON_INLINE
int
__Pyx_PySet_Remove
(
PyObject
*
set
,
PyObject
*
key
);
/*proto*/
static
CYTHON_INLINE
int
__Pyx_PySet_Remove
(
PyObject
*
set
,
PyObject
*
key
);
/*proto*/
/////////////// py_set_remove ///////////////
/////////////// py_set_remove ///////////////
//@requires: py_set_discard_unhashable
static
CYTHON_INLINE
int
__Pyx_PySet_Remove
(
PyObject
*
set
,
PyObject
*
key
)
{
static
CYTHON_INLINE
int
__Pyx_PySet_Remove
(
PyObject
*
set
,
PyObject
*
key
)
{
PyObject
*
tmpkey
;
int
rv
;
int
rv
;
rv
=
PySet_Discard
(
set
,
key
);
rv
=
PySet_Discard
(
set
,
key
);
/* Convert *key* to frozenset if necessary */
/* Convert *key* to frozenset if necessary */
if
(
rv
<
0
)
{
if
(
unlikely
(
rv
<
0
))
{
if
(
!
PySet_Check
(
key
)
||
!
PyErr_ExceptionMatches
(
PyExc_TypeError
))
rv
=
__Pyx_PySet_DiscardUnhashable
(
set
,
key
);
return
-
1
;
PyErr_Clear
();
tmpkey
=
PyFrozenSet_New
(
key
);
if
(
tmpkey
==
NULL
)
return
-
1
;
rv
=
PySet_Discard
(
set
,
tmpkey
);
Py_DECREF
(
tmpkey
);
}
}
if
(
rv
==
0
)
{
if
(
rv
==
0
)
{
/* Not found */
/* Not found */
...
...
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