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
875f29bb
Kaydet (Commit)
875f29bb
authored
Eki 04, 2011
tarafından
Antoine Pitrou
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Fix naïve heuristic in unicode slicing (followup to 1b4f886dc9e2)
üst
2b72f838
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
7 deletions
+15
-7
unicodeobject.c
Objects/unicodeobject.c
+15
-7
No files found.
Objects/unicodeobject.c
Dosyayı görüntüle @
875f29bb
...
@@ -12258,7 +12258,8 @@ unicode_subscript(PyUnicodeObject* self, PyObject* item)
...
@@ -12258,7 +12258,8 @@ unicode_subscript(PyUnicodeObject* self, PyObject* item)
Py_ssize_t start, stop, step, slicelength, cur, i;
Py_ssize_t start, stop, step, slicelength, cur, i;
PyObject *result;
PyObject *result;
void *src_data, *dest_data;
void *src_data, *dest_data;
int kind;
int src_kind, dest_kind;
Py_UCS4 ch, max_char;
if (PySlice_GetIndicesEx(item, PyUnicode_GET_LENGTH(self),
if (PySlice_GetIndicesEx(item, PyUnicode_GET_LENGTH(self),
&start, &stop, &step, &slicelength) < 0) {
&start, &stop, &step, &slicelength) < 0) {
...
@@ -12276,17 +12277,24 @@ unicode_subscript(PyUnicodeObject* self, PyObject* item)
...
@@ -12276,17 +12277,24 @@ unicode_subscript(PyUnicodeObject* self, PyObject* item)
return PyUnicode_Substring((PyObject*)self,
return PyUnicode_Substring((PyObject*)self,
start, start + slicelength);
start, start + slicelength);
}
}
/* General (less optimized) case */
/* General case */
result = PyUnicode_New(slicelength, PyUnicode_MAX_CHAR_VALUE(self));
max_char = 127;
src_kind = PyUnicode_KIND(self);
src_data = PyUnicode_DATA(self);
for (cur = start, i = 0; i < slicelength; cur += step, i++) {
ch = PyUnicode_READ(src_kind, src_data, cur);
if (ch > max_char)
max_char = ch;
}
result = PyUnicode_New(slicelength, max_char);
if (result == NULL)
if (result == NULL)
return NULL;
return NULL;
kind = PyUnicode_KIND(self);
dest_kind = PyUnicode_KIND(result);
src_data = PyUnicode_DATA(self);
dest_data = PyUnicode_DATA(result);
dest_data = PyUnicode_DATA(result);
for (cur = start, i = 0; i < slicelength; cur += step, i++) {
for (cur = start, i = 0; i < slicelength; cur += step, i++) {
Py_UCS4 ch = PyUnicode_READ(kind, src_data, cur);
Py_UCS4 ch = PyUnicode_READ(
src_
kind, src_data, cur);
PyUnicode_WRITE(kind, dest_data, i, ch);
PyUnicode_WRITE(
dest_
kind, dest_data, i, ch);
}
}
return result;
return result;
} else {
} else {
...
...
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