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
f30f5b9b
Kaydet (Commit)
f30f5b9b
authored
Mar 03, 2015
tarafından
Raymond Hettinger
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Minor code beautification. Replace macro with in-lineable functions.
üst
3c186ba4
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
35 additions
and
20 deletions
+35
-20
_collectionsmodule.c
Modules/_collectionsmodule.c
+35
-20
No files found.
Modules/_collectionsmodule.c
Dosyayı görüntüle @
f30f5b9b
...
...
@@ -130,22 +130,6 @@ typedef struct {
PyObject
*
weakreflist
;
/* List of weak references */
}
dequeobject
;
/* The deque's size limit is d.maxlen. The limit can be zero or positive.
* If there is no limit, then d.maxlen == -1.
*
* After an item is added to a deque, we check to see if the size has grown past
* the limit. If it has, we get the size back down to the limit by popping an
* item off of the opposite end. The methods that can trigger this are append(),
* appendleft(), extend(), and extendleft().
*/
#define TRIM(d, popfunction) \
if (d->maxlen != -1 && Py_SIZE(d) > d->maxlen) { \
PyObject *rv = popfunction(d, NULL); \
assert(rv != NULL && Py_SIZE(d) <= d->maxlen); \
Py_DECREF(rv); \
}
static
PyTypeObject
deque_type
;
/* XXX Todo:
...
...
@@ -261,6 +245,37 @@ deque_popleft(dequeobject *deque, PyObject *unused)
PyDoc_STRVAR
(
popleft_doc
,
"Remove and return the leftmost element."
);
/* The deque's size limit is d.maxlen. The limit can be zero or positive.
* If there is no limit, then d.maxlen == -1.
*
* After an item is added to a deque, we check to see if the size has grown past
* the limit. If it has, we get the size back down to the limit by popping an
* item off of the opposite end. The methods that can trigger this are append(),
* appendleft(), extend(), and extendleft().
*/
static
void
deque_trim_right
(
dequeobject
*
deque
)
{
if
(
deque
->
maxlen
!=
-
1
&&
Py_SIZE
(
deque
)
>
deque
->
maxlen
)
{
PyObject
*
rv
=
deque_pop
(
deque
,
NULL
);
assert
(
rv
!=
NULL
);
assert
(
Py_SIZE
(
deque
)
<=
deque
->
maxlen
);
Py_DECREF
(
rv
);
}
}
static
void
deque_trim_left
(
dequeobject
*
deque
)
{
if
(
deque
->
maxlen
!=
-
1
&&
Py_SIZE
(
deque
)
>
deque
->
maxlen
)
{
PyObject
*
rv
=
deque_popleft
(
deque
,
NULL
);
assert
(
rv
!=
NULL
);
assert
(
Py_SIZE
(
deque
)
<=
deque
->
maxlen
);
Py_DECREF
(
rv
);
}
}
static
PyObject
*
deque_append
(
dequeobject
*
deque
,
PyObject
*
item
)
{
...
...
@@ -280,7 +295,7 @@ deque_append(dequeobject *deque, PyObject *item)
Py_SIZE
(
deque
)
++
;
deque
->
rightindex
++
;
deque
->
rightblock
->
data
[
deque
->
rightindex
]
=
item
;
TRIM
(
deque
,
deque_popleft
);
deque_trim_left
(
deque
);
Py_RETURN_NONE
;
}
...
...
@@ -305,7 +320,7 @@ deque_appendleft(dequeobject *deque, PyObject *item)
Py_SIZE
(
deque
)
++
;
deque
->
leftindex
--
;
deque
->
leftblock
->
data
[
deque
->
leftindex
]
=
item
;
TRIM
(
deque
,
deque_pop
);
deque_trim_right
(
deque
);
Py_RETURN_NONE
;
}
...
...
@@ -378,7 +393,7 @@ deque_extend(dequeobject *deque, PyObject *iterable)
Py_SIZE
(
deque
)
++
;
deque
->
rightindex
++
;
deque
->
rightblock
->
data
[
deque
->
rightindex
]
=
item
;
TRIM
(
deque
,
deque_popleft
);
deque_trim_left
(
deque
);
}
Py_DECREF
(
it
);
if
(
PyErr_Occurred
())
...
...
@@ -439,7 +454,7 @@ deque_extendleft(dequeobject *deque, PyObject *iterable)
Py_SIZE
(
deque
)
++
;
deque
->
leftindex
--
;
deque
->
leftblock
->
data
[
deque
->
leftindex
]
=
item
;
TRIM
(
deque
,
deque_pop
);
deque_trim_right
(
deque
);
}
Py_DECREF
(
it
);
if
(
PyErr_Occurred
())
...
...
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