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
eb4b5ac8
Kaydet (Commit)
eb4b5ac8
authored
Nis 03, 2013
tarafından
Victor Stinner
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Close #16757: Avoid calling the expensive _PyUnicode_FindMaxChar() function
when possible
üst
cfc4c13b
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
8 deletions
+15
-8
unicodeobject.c
Objects/unicodeobject.c
+10
-7
formatter_unicode.c
Python/formatter_unicode.c
+5
-1
No files found.
Objects/unicodeobject.c
Dosyayı görüntüle @
eb4b5ac8
...
...
@@ -13777,7 +13777,7 @@ unicode_format_arg_output(struct unicode_formatter_t *ctx,
Py_ssize_t pindex;
Py_UCS4 signchar;
Py_ssize_t buflen;
Py_UCS4 maxchar
, bufmaxchar
;
Py_UCS4 maxchar;
Py_ssize_t sublen;
_PyUnicodeWriter *writer = &ctx->writer;
Py_UCS4 fill;
...
...
@@ -13830,23 +13830,26 @@ unicode_format_arg_output(struct unicode_formatter_t *ctx,
arg->width = len;
/* Prepare the writer */
bufmaxchar = 127
;
maxchar = writer->maxchar
;
if (!(arg->flags & F_LJUST)) {
if (arg->sign) {
if ((arg->width-1) > len)
bufmaxchar = MAX_MAXCHAR(buf
maxchar, fill);
maxchar = MAX_MAXCHAR(
maxchar, fill);
}
else {
if (arg->width > len)
bufmaxchar = MAX_MAXCHAR(buf
maxchar, fill);
maxchar = MAX_MAXCHAR(
maxchar, fill);
}
}
maxchar = _PyUnicode_FindMaxChar(str, 0, pindex+len);
bufmaxchar = MAX_MAXCHAR(bufmaxchar, maxchar);
if (PyUnicode_MAX_CHAR_VALUE(str) > maxchar) {
Py_UCS4 strmaxchar = _PyUnicode_FindMaxChar(str, 0, pindex+len);
maxchar = MAX_MAXCHAR(maxchar, strmaxchar);
}
buflen = arg->width;
if (arg->sign && len == arg->width)
buflen++;
if (_PyUnicodeWriter_Prepare(writer, buflen,
buf
maxchar) == -1)
if (_PyUnicodeWriter_Prepare(writer, buflen, maxchar) == -1)
return -1;
/* Write the sign if needed */
...
...
Python/formatter_unicode.c
Dosyayı görüntüle @
eb4b5ac8
...
...
@@ -771,9 +771,13 @@ format_string_internal(PyObject *value, const InternalFormatSpec *format,
calc_padding
(
len
,
format
->
width
,
format
->
align
,
&
lpad
,
&
rpad
,
&
total
);
maxchar
=
_PyUnicode_FindMaxChar
(
value
,
0
,
len
)
;
maxchar
=
writer
->
maxchar
;
if
(
lpad
!=
0
||
rpad
!=
0
)
maxchar
=
Py_MAX
(
maxchar
,
format
->
fill_char
);
if
(
PyUnicode_MAX_CHAR_VALUE
(
value
)
>
maxchar
)
{
Py_UCS4
valmaxchar
=
_PyUnicode_FindMaxChar
(
value
,
0
,
len
);
maxchar
=
Py_MAX
(
maxchar
,
valmaxchar
);
}
/* allocate the resulting string */
if
(
_PyUnicodeWriter_Prepare
(
writer
,
total
,
maxchar
)
==
-
1
)
...
...
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