Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
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
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
e1b0287c
Commit
e1b0287c
authored
Sep 04, 2017
by
Raymond Hettinger
Committed by
GitHub
Sep 04, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Code clean-up. Remove unnecessary pre-increment before the loop starts. (#3312)
parent
af64aff9
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
17 deletions
+10
-17
Modules/_collectionsmodule.c
Modules/_collectionsmodule.c
+10
-17
No files found.
Modules/_collectionsmodule.c
View file @
e1b0287c
...
...
@@ -938,8 +938,7 @@ deque_reverse(dequeobject *deque, PyObject *unused)
Py_ssize_t
n
=
Py_SIZE
(
deque
)
>>
1
;
PyObject
*
tmp
;
n
++
;
while
(
--
n
)
{
while
(
--
n
>=
0
)
{
/* Validate that pointers haven't met in the middle */
assert
(
leftblock
!=
rightblock
||
leftindex
<
rightindex
);
CHECK_NOT_END
(
leftblock
);
...
...
@@ -981,8 +980,7 @@ deque_count(dequeobject *deque, PyObject *v)
PyObject
*
item
;
int
cmp
;
n
++
;
while
(
--
n
)
{
while
(
--
n
>=
0
)
{
CHECK_NOT_END
(
b
);
item
=
b
->
data
[
index
];
cmp
=
PyObject_RichCompareBool
(
item
,
v
,
Py_EQ
);
...
...
@@ -1019,8 +1017,7 @@ deque_contains(dequeobject *deque, PyObject *v)
PyObject
*
item
;
int
cmp
;
n
++
;
while
(
--
n
)
{
while
(
--
n
>=
0
)
{
CHECK_NOT_END
(
b
);
item
=
b
->
data
[
index
];
cmp
=
PyObject_RichCompareBool
(
item
,
v
,
Py_EQ
);
...
...
@@ -1088,13 +1085,13 @@ deque_index(dequeobject *deque, PyObject **args, Py_ssize_t nargs)
}
}
n
=
stop
-
i
+
1
;
while
(
--
n
)
{
n
=
stop
-
i
;
while
(
--
n
>=
0
)
{
CHECK_NOT_END
(
b
);
item
=
b
->
data
[
index
];
cmp
=
PyObject_RichCompareBool
(
item
,
v
,
Py_EQ
);
if
(
cmp
>
0
)
return
PyLong_FromSsize_t
(
stop
-
n
);
return
PyLong_FromSsize_t
(
stop
-
n
-
1
);
if
(
cmp
<
0
)
return
NULL
;
if
(
start_state
!=
deque
->
state
)
{
...
...
@@ -1228,16 +1225,14 @@ deque_item(dequeobject *deque, Py_ssize_t i)
i
=
(
Py_ssize_t
)((
size_t
)
i
%
BLOCKLEN
);
if
(
index
<
(
Py_SIZE
(
deque
)
>>
1
))
{
b
=
deque
->
leftblock
;
n
++
;
while
(
--
n
)
while
(
--
n
>=
0
)
b
=
b
->
rightlink
;
}
else
{
n
=
(
Py_ssize_t
)(
((
size_t
)(
deque
->
leftindex
+
Py_SIZE
(
deque
)
-
1
))
/
BLOCKLEN
-
n
);
b
=
deque
->
rightblock
;
n
++
;
while
(
--
n
)
while
(
--
n
>=
0
)
b
=
b
->
leftlink
;
}
}
...
...
@@ -1281,16 +1276,14 @@ deque_ass_item(dequeobject *deque, Py_ssize_t i, PyObject *v)
i
=
(
Py_ssize_t
)((
size_t
)
i
%
BLOCKLEN
);
if
(
index
<=
halflen
)
{
b
=
deque
->
leftblock
;
n
++
;
while
(
--
n
)
while
(
--
n
>=
0
)
b
=
b
->
rightlink
;
}
else
{
n
=
(
Py_ssize_t
)(
((
size_t
)(
deque
->
leftindex
+
Py_SIZE
(
deque
)
-
1
))
/
BLOCKLEN
-
n
);
b
=
deque
->
rightblock
;
n
++
;
while
(
--
n
)
while
(
--
n
>=
0
)
b
=
b
->
leftlink
;
}
Py_INCREF
(
v
);
...
...
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