Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
cpython
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
cpython
Commits
dcb9d946
Kaydet (Commit)
dcb9d946
authored
Eki 09, 2004
tarafından
Raymond Hettinger
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Simplify delitem() code by calling rotate() directly instead of using
arguments passed through tuples.
üst
7126976e
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
23 additions
and
35 deletions
+23
-35
collectionsmodule.c
Modules/collectionsmodule.c
+23
-35
No files found.
Modules/collectionsmodule.c
Dosyayı görüntüle @
dcb9d946
...
...
@@ -310,17 +310,14 @@ deque_extendleft(dequeobject *deque, PyObject *iterable)
PyDoc_STRVAR
(
extendleft_doc
,
"Extend the left side of the deque with elements from the iterable"
);
static
PyObject
*
deque_rotate
(
dequeobject
*
deque
,
PyObject
*
args
)
static
int
_deque_rotate
(
dequeobject
*
deque
,
int
n
)
{
int
i
,
n
=
1
,
len
=
deque
->
len
,
halflen
=
(
len
+
1
)
>>
1
;
int
i
,
len
=
deque
->
len
,
halflen
=
(
len
+
1
)
>>
1
;
PyObject
*
item
,
*
rv
;
if
(
!
PyArg_ParseTuple
(
args
,
"|i:rotate"
,
&
n
))
return
NULL
;
if
(
len
==
0
)
Py_RETURN_NONE
;
return
0
;
if
(
n
>
halflen
||
n
<
-
halflen
)
{
n
%=
len
;
if
(
n
>
halflen
)
...
...
@@ -335,7 +332,7 @@ deque_rotate(dequeobject *deque, PyObject *args)
rv
=
deque_appendleft
(
deque
,
item
);
Py_DECREF
(
item
);
if
(
rv
==
NULL
)
return
NULL
;
return
-
1
;
Py_DECREF
(
rv
);
}
for
(
i
=
0
;
i
>
n
;
i
--
)
{
...
...
@@ -344,10 +341,22 @@ deque_rotate(dequeobject *deque, PyObject *args)
rv
=
deque_append
(
deque
,
item
);
Py_DECREF
(
item
);
if
(
rv
==
NULL
)
return
NULL
;
return
-
1
;
Py_DECREF
(
rv
);
}
Py_RETURN_NONE
;
return
0
;
}
static
PyObject
*
deque_rotate
(
dequeobject
*
deque
,
PyObject
*
args
)
{
int
n
=
1
;
if
(
!
PyArg_ParseTuple
(
args
,
"|i:rotate"
,
&
n
))
return
NULL
;
if
(
_deque_rotate
(
deque
,
n
)
==
0
)
Py_RETURN_NONE
;
return
NULL
;
}
PyDoc_STRVAR
(
rotate_doc
,
...
...
@@ -424,38 +433,17 @@ deque_item(dequeobject *deque, int i)
static
int
deque_del_item
(
dequeobject
*
deque
,
int
i
)
{
PyObject
*
item
=
NULL
,
*
minus_i
=
NULL
,
*
plus_i
=
NULL
;
int
rv
=
-
1
;
PyObject
*
item
;
assert
(
i
>=
0
&&
i
<
deque
->
len
);
minus_i
=
Py_BuildValue
(
"(i)"
,
-
i
);
if
(
minus_i
==
NULL
)
goto
fail
;
plus_i
=
Py_BuildValue
(
"(i)"
,
i
);
if
(
plus_i
==
NULL
)
goto
fail
;
item
=
deque_rotate
(
deque
,
minus_i
);
if
(
item
==
NULL
)
goto
fail
;
Py_DECREF
(
item
);
if
(
_deque_rotate
(
deque
,
-
i
)
==
-
1
)
return
-
1
;
item
=
deque_popleft
(
deque
,
NULL
);
assert
(
item
!=
NULL
);
Py_DECREF
(
item
);
item
=
deque_rotate
(
deque
,
plus_i
);
if
(
item
==
NULL
)
goto
fail
;
rv
=
0
;
fail:
Py_XDECREF
(
item
);
Py_XDECREF
(
minus_i
);
Py_XDECREF
(
plus_i
);
return
rv
;
return
_deque_rotate
(
deque
,
i
);
}
static
int
...
...
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