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
1f932619
Kaydet (Commit)
1f932619
authored
Agu 29, 2016
tarafından
Serhiy Storchaka
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Issue #27818: Speed up parsing width and precision in format() strings for
numbers. Patch by Stefan Behnel.
üst
8631da64
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
9 deletions
+16
-9
formatter_unicode.c
Python/formatter_unicode.c
+16
-9
No files found.
Python/formatter_unicode.c
Dosyayı görüntüle @
1f932619
...
@@ -48,16 +48,17 @@ invalid_comma_type(Py_UCS4 presentation_type)
...
@@ -48,16 +48,17 @@ invalid_comma_type(Py_UCS4 presentation_type)
returns -1 on error.
returns -1 on error.
*/
*/
static
int
static
int
get_integer
(
PyObject
*
str
,
Py_ssize_t
*
pos
,
Py_ssize_t
end
,
get_integer
(
PyObject
*
str
,
Py_ssize_t
*
p
p
os
,
Py_ssize_t
end
,
Py_ssize_t
*
result
)
Py_ssize_t
*
result
)
{
{
Py_ssize_t
accumulator
,
digitval
;
Py_ssize_t
accumulator
,
digitval
,
pos
=
*
ppos
;
int
numdigits
;
int
numdigits
;
int
kind
=
PyUnicode_KIND
(
str
);
void
*
data
=
PyUnicode_DATA
(
str
);
accumulator
=
numdigits
=
0
;
accumulator
=
numdigits
=
0
;
for
(;;(
*
pos
)
++
,
numdigits
++
)
{
for
(;
pos
<
end
;
pos
++
,
numdigits
++
)
{
if
(
*
pos
>=
end
)
digitval
=
Py_UNICODE_TODECIMAL
(
PyUnicode_READ
(
kind
,
data
,
pos
));
break
;
digitval
=
Py_UNICODE_TODECIMAL
(
PyUnicode_READ_CHAR
(
str
,
*
pos
));
if
(
digitval
<
0
)
if
(
digitval
<
0
)
break
;
break
;
/*
/*
...
@@ -69,10 +70,12 @@ get_integer(PyObject *str, Py_ssize_t *pos, Py_ssize_t end,
...
@@ -69,10 +70,12 @@ get_integer(PyObject *str, Py_ssize_t *pos, Py_ssize_t end,
if
(
accumulator
>
(
PY_SSIZE_T_MAX
-
digitval
)
/
10
)
{
if
(
accumulator
>
(
PY_SSIZE_T_MAX
-
digitval
)
/
10
)
{
PyErr_Format
(
PyExc_ValueError
,
PyErr_Format
(
PyExc_ValueError
,
"Too many decimal digits in format string"
);
"Too many decimal digits in format string"
);
*
ppos
=
pos
;
return
-
1
;
return
-
1
;
}
}
accumulator
=
accumulator
*
10
+
digitval
;
accumulator
=
accumulator
*
10
+
digitval
;
}
}
*
ppos
=
pos
;
*
result
=
accumulator
;
*
result
=
accumulator
;
return
numdigits
;
return
numdigits
;
}
}
...
@@ -150,9 +153,11 @@ parse_internal_render_format_spec(PyObject *format_spec,
...
@@ -150,9 +153,11 @@ parse_internal_render_format_spec(PyObject *format_spec,
char
default_align
)
char
default_align
)
{
{
Py_ssize_t
pos
=
start
;
Py_ssize_t
pos
=
start
;
int
kind
=
PyUnicode_KIND
(
format_spec
);
void
*
data
=
PyUnicode_DATA
(
format_spec
);
/* end-pos is used throughout this code to specify the length of
/* end-pos is used throughout this code to specify the length of
the input string */
the input string */
#define READ_spec(index) PyUnicode_READ
_CHAR(format_spec
, index)
#define READ_spec(index) PyUnicode_READ
(kind, data
, index)
Py_ssize_t
consumed
;
Py_ssize_t
consumed
;
int
align_specified
=
0
;
int
align_specified
=
0
;
...
@@ -402,13 +407,15 @@ parse_number(PyObject *s, Py_ssize_t pos, Py_ssize_t end,
...
@@ -402,13 +407,15 @@ parse_number(PyObject *s, Py_ssize_t pos, Py_ssize_t end,
Py_ssize_t
*
n_remainder
,
int
*
has_decimal
)
Py_ssize_t
*
n_remainder
,
int
*
has_decimal
)
{
{
Py_ssize_t
remainder
;
Py_ssize_t
remainder
;
int
kind
=
PyUnicode_KIND
(
s
);
void
*
data
=
PyUnicode_DATA
(
s
);
while
(
pos
<
end
&&
Py_ISDIGIT
(
PyUnicode_READ
_CHAR
(
s
,
pos
)))
while
(
pos
<
end
&&
Py_ISDIGIT
(
PyUnicode_READ
(
kind
,
data
,
pos
)))
++
pos
;
++
pos
;
remainder
=
pos
;
remainder
=
pos
;
/* Does remainder start with a decimal point? */
/* Does remainder start with a decimal point? */
*
has_decimal
=
pos
<
end
&&
PyUnicode_READ
_CHAR
(
s
,
remainder
)
==
'.'
;
*
has_decimal
=
pos
<
end
&&
PyUnicode_READ
(
kind
,
data
,
remainder
)
==
'.'
;
/* Skip the decimal point. */
/* Skip the decimal point. */
if
(
*
has_decimal
)
if
(
*
has_decimal
)
...
...
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