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
afb5205c
Kaydet (Commit)
afb5205c
authored
Nis 05, 2012
tarafından
Victor Stinner
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Close #14249: Use bit shifts instead of an union, it's more efficient.
Patch written by Serhiy Storchaka
üst
02184282
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
35 additions
and
27 deletions
+35
-27
ACKS
Misc/ACKS
+1
-0
unicodeobject.c
Objects/unicodeobject.c
+34
-27
No files found.
Misc/ACKS
Dosyayı görüntüle @
afb5205c
...
...
@@ -977,6 +977,7 @@ Richard Stoakley
Peter Stoehr
Casper Stoel
Michael Stone
Serhiy Storchaka
Ken Stox
Dan Stromberg
Daniel Stutzbach
...
...
Objects/unicodeobject.c
Dosyayı görüntüle @
afb5205c
...
...
@@ -5393,9 +5393,11 @@ PyUnicode_DecodeUTF16(const char *s,
#if (SIZEOF_LONG == 8)
# define FAST_CHAR_MASK 0x8000800080008000L
# define SWAPPED_FAST_CHAR_MASK 0x0080008000800080L
# define STRIPPED_MASK 0x00FF00FF00FF00FFL
#elif (SIZEOF_LONG == 4)
# define FAST_CHAR_MASK 0x80008000L
# define SWAPPED_FAST_CHAR_MASK 0x00800080L
# define STRIPPED_MASK 0x00FF00FFL
#else
# error C 'long' size should be either 4 or 8!
#endif
...
...
@@ -5496,39 +5498,31 @@ PyUnicode_DecodeUTF16Stateful(const char *s,
int kind = PyUnicode_KIND(unicode);
void *data = PyUnicode_DATA(unicode);
while (_q < aligned_end) {
union {
unsigned long as_long;
unsigned short units[sizeof(long) / sizeof(short)];
unsigned char bytes[sizeof(long)];
} block, block_copy;
unsigned long block = * (unsigned long *) _q;
Py_UCS4 maxch;
block.as_long = *(unsigned long *) _q;
if (native_ordering) {
/* Can use buffer directly */
if (block
.as_long
& FAST_CHAR_MASK)
if (block & FAST_CHAR_MASK)
break;
}
else {
/* Need to byte-swap */
block_copy = block;
if (block.as_long & SWAPPED_FAST_CHAR_MASK)
if (block & SWAPPED_FAST_CHAR_MASK)
break;
block.bytes[0] = block_copy.bytes[1];
block.bytes[1] = block_copy.bytes[0];
block.bytes[2] = block_copy.bytes[3];
block.bytes[3] = block_copy.bytes[2];
#if (SIZEOF_LONG == 8)
block.bytes[4] = block_copy.bytes[5];
block.bytes[5] = block_copy.bytes[4];
block.bytes[6] = block_copy.bytes[7];
block.bytes[7] = block_copy.bytes[6];
#endif
block = ((block >> 8) & STRIPPED_MASK) |
((block & STRIPPED_MASK) << 8);
}
maxch =
Py_MAX(block.units[0], block.units[1]
);
maxch =
(Py_UCS2)(block & 0xFFFF
);
#if SIZEOF_LONG == 8
maxch = Py_MAX(maxch, Py_MAX(block.units[2], block.units[3]));
ch = (Py_UCS2)((block >> 16) & 0xFFFF);
maxch = Py_MAX(maxch, ch);
ch = (Py_UCS2)((block >> 32) & 0xFFFF);
maxch = Py_MAX(maxch, ch);
ch = (Py_UCS2)(block >> 48);
maxch = Py_MAX(maxch, ch);
#else
ch = (Py_UCS2)(block >> 16);
maxch = Py_MAX(maxch, ch);
#endif
if (maxch > PyUnicode_MAX_CHAR_VALUE(unicode)) {
if (unicode_widen(&unicode, maxch) < 0)
...
...
@@ -5536,11 +5530,24 @@ PyUnicode_DecodeUTF16Stateful(const char *s,
kind = PyUnicode_KIND(unicode);
data = PyUnicode_DATA(unicode);
}
PyUnicode_WRITE(kind, data, outpos++, block.units[0]);
PyUnicode_WRITE(kind, data, outpos++,
block.units[1]
);
#ifdef BYTEORDER_IS_LITTLE_ENDIAN
PyUnicode_WRITE(kind, data, outpos++,
(Py_UCS2)(block & 0xFFFF)
);
#if SIZEOF_LONG == 8
PyUnicode_WRITE(kind, data, outpos++, block.units[2]);
PyUnicode_WRITE(kind, data, outpos++, block.units[3]);
PyUnicode_WRITE(kind, data, outpos++, (Py_UCS2)((block >> 16) & 0xFFFF));
PyUnicode_WRITE(kind, data, outpos++, (Py_UCS2)((block >> 32) & 0xFFFF));
PyUnicode_WRITE(kind, data, outpos++, (Py_UCS2)((block >> 48)));
#else
PyUnicode_WRITE(kind, data, outpos++, (Py_UCS2)(block >> 16));
#endif
#else
#if SIZEOF_LONG == 8
PyUnicode_WRITE(kind, data, outpos++, (Py_UCS2)((block >> 48)));
PyUnicode_WRITE(kind, data, outpos++, (Py_UCS2)((block >> 32) & 0xFFFF));
PyUnicode_WRITE(kind, data, outpos++, (Py_UCS2)((block >> 16) & 0xFFFF));
#else
PyUnicode_WRITE(kind, data, outpos++, (Py_UCS2)(block >> 16));
#endif
PyUnicode_WRITE(kind, data, outpos++, (Py_UCS2)(block & 0xFFFF));
#endif
_q += SIZEOF_LONG;
}
...
...
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