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
88d146b7
Commit
88d146b7
authored
Aug 17, 2014
by
Victor Stinner
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Optimize PyBytes_FromObject(): only overallocate when size=0 to not get the
empty string singleton
parent
cfcde8ca
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
3 additions
and
1 deletion
+3
-1
Objects/bytesobject.c
Objects/bytesobject.c
+3
-1
No files found.
Objects/bytesobject.c
View file @
88d146b7
...
...
@@ -3174,10 +3174,12 @@ PyBytes_FromObject(PyObject *x)
returning a shared empty bytes string. This required because we
want to call _PyBytes_Resize() the returned object, which we can
only do on bytes objects with refcount == 1. */
size
+=
1
;
if
(
size
==
0
)
size
=
1
;
new
=
PyBytes_FromStringAndSize
(
NULL
,
size
);
if
(
new
==
NULL
)
return
NULL
;
assert
(
Py_REFCNT
(
new
)
==
1
);
/* Get the iterator */
it
=
PyObject_GetIter
(
x
);
...
...
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