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
770e19e0
Kaydet (Commit)
770e19e0
authored
Eki 04, 2012
tarafından
Victor Stinner
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Optimize unicode_compare(): use memcmp() when comparing two UCS1 strings
üst
90db9c47
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
25 additions
and
8 deletions
+25
-8
unicodeobject.c
Objects/unicodeobject.c
+25
-8
No files found.
Objects/unicodeobject.c
Dosyayı görüntüle @
770e19e0
...
...
@@ -10443,7 +10443,8 @@ unicode_compare(PyObject *str1, PyObject *str2)
{
int kind1, kind2;
void *data1, *data2;
Py_ssize_t len1, len2, i;
Py_ssize_t len1, len2;
Py_ssize_t i, len;
/* a string is equal to itself */
if (str1 == str2)
...
...
@@ -10455,17 +10456,33 @@ unicode_compare(PyObject *str1, PyObject *str2)
data2 = PyUnicode_DATA(str2);
len1 = PyUnicode_GET_LENGTH(str1);
len2 = PyUnicode_GET_LENGTH(str2);
len = Py_MIN(len1, len2);
for (i = 0; i < len1 && i < len2; ++i) {
Py_UCS4 c1, c2;
c1 = PyUnicode_READ(kind1, data1, i);
c2 = PyUnicode_READ(kind2, data2, i);
if (kind1 == 1 && kind2 == 1) {
int cmp = memcmp(data1, data2, len);
/* normalize result of memcmp() into the range [-1; 1] */
if (cmp < 0)
return -1;
if (cmp > 0)
return 1;
}
else {
for (i = 0; i < len; ++i) {
Py_UCS4 c1, c2;
c1 = PyUnicode_READ(kind1, data1, i);
c2 = PyUnicode_READ(kind2, data2, i);
if (c1 != c2)
return (c1 < c2) ? -1 : 1;
if (c1 != c2)
return (c1 < c2) ? -1 : 1;
}
}
return (len1 < len2) ? -1 : (len1 != len2);
if (len1 == len2)
return 0;
if (len1 < len2)
return -1;
else
return 1;
}
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