Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
5489a69b
Commit
5489a69b
authored
Apr 12, 2009
by
Georg Brandl
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
#5708: a bit of streamlining in unicode_repeat().
parent
e14cd9e9
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
9 deletions
+8
-9
Objects/unicodeobject.c
Objects/unicodeobject.c
+8
-9
No files found.
Objects/unicodeobject.c
View file @
5489a69b
...
...
@@ -7738,8 +7738,10 @@ unicode_repeat(PyUnicodeObject *str, Py_ssize_t len)
Py_ssize_t
nchars
;
size_t
nbytes
;
if
(
len
<
0
)
len
=
0
;
if
(
len
<
1
)
{
Py_INCREF
(
unicode_empty
);
return
(
PyObject
*
)
unicode_empty
;
}
if
(
len
==
1
&&
PyUnicode_CheckExact
(
str
))
{
/* no repeat, return original string */
...
...
@@ -7751,7 +7753,7 @@ unicode_repeat(PyUnicodeObject *str, Py_ssize_t len)
* needed doesn't overflow size_t
*/
nchars
=
len
*
str
->
length
;
if
(
len
&&
nchars
/
len
!=
str
->
length
)
{
if
(
nchars
/
len
!=
str
->
length
)
{
PyErr_SetString
(
PyExc_OverflowError
,
"repeated string is too long"
);
return
NULL
;
...
...
@@ -7768,14 +7770,11 @@ unicode_repeat(PyUnicodeObject *str, Py_ssize_t len)
p
=
u
->
str
;
if
(
str
->
length
==
1
&&
len
>
0
)
{
if
(
str
->
length
==
1
)
{
Py_UNICODE_FILL
(
p
,
str
->
str
[
0
],
len
);
}
else
{
Py_ssize_t
done
=
0
;
/* number of characters copied this far */
if
(
done
<
nchars
)
{
Py_ssize_t
done
=
str
->
length
;
/* number of characters copied this far */
Py_UNICODE_COPY
(
p
,
str
->
str
,
str
->
length
);
done
=
str
->
length
;
}
while
(
done
<
nchars
)
{
Py_ssize_t
n
=
(
done
<=
nchars
-
done
)
?
done
:
nchars
-
done
;
Py_UNICODE_COPY
(
p
+
done
,
p
,
n
);
...
...
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