Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
D
django
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
django
Commits
b80be68e
Kaydet (Commit)
b80be68e
authored
Eyl 06, 2013
tarafından
Aymeric Augustin
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Fixed #21052 -- Small performance optimization.
üst
e492ab8e
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
4 additions
and
4 deletions
+4
-4
encoding.py
django/utils/encoding.py
+4
-4
No files found.
django/utils/encoding.py
Dosyayı görüntüle @
b80be68e
...
...
@@ -60,8 +60,7 @@ def force_text(s, encoding='utf-8', strings_only=False, errors='strict'):
If strings_only is True, don't convert (some) non-string-like objects.
"""
# Handle the common case first, saves 30-40% when s is an instance of
# six.text_type. This function gets called often in that setting.
# Handle the common case first for performance reasons.
if
isinstance
(
s
,
six
.
text_type
):
return
s
if
strings_only
and
is_protected_type
(
s
):
...
...
@@ -115,8 +114,7 @@ def force_bytes(s, encoding='utf-8', strings_only=False, errors='strict'):
If strings_only is True, don't convert (some) non-string-like objects.
"""
if
isinstance
(
s
,
six
.
memoryview
):
s
=
bytes
(
s
)
# Handle the common case first for performance reasons.
if
isinstance
(
s
,
bytes
):
if
encoding
==
'utf-8'
:
return
s
...
...
@@ -124,6 +122,8 @@ def force_bytes(s, encoding='utf-8', strings_only=False, errors='strict'):
return
s
.
decode
(
'utf-8'
,
errors
)
.
encode
(
encoding
,
errors
)
if
strings_only
and
is_protected_type
(
s
):
return
s
if
isinstance
(
s
,
six
.
memoryview
):
return
bytes
(
s
)
if
isinstance
(
s
,
Promise
):
return
six
.
text_type
(
s
)
.
encode
(
encoding
,
errors
)
if
not
isinstance
(
s
,
six
.
string_types
):
...
...
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