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
85d6edfc
Commit
85d6edfc
authored
Feb 09, 2001
by
Marc-André Lemburg
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove silly EMPTYSTRING global. Saves a global lookup.
parent
b3acd3e4
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
8 deletions
+6
-8
Lib/StringIO.py
Lib/StringIO.py
+6
-8
No files found.
Lib/StringIO.py
View file @
85d6edfc
...
@@ -36,8 +36,6 @@ except ImportError:
...
@@ -36,8 +36,6 @@ except ImportError:
__all__
=
[
"StringIO"
]
__all__
=
[
"StringIO"
]
EMPTYSTRING
=
''
class
StringIO
:
class
StringIO
:
def
__init__
(
self
,
buf
=
''
):
def
__init__
(
self
,
buf
=
''
):
self
.
buf
=
buf
self
.
buf
=
buf
...
@@ -61,7 +59,7 @@ class StringIO:
...
@@ -61,7 +59,7 @@ class StringIO:
if
self
.
closed
:
if
self
.
closed
:
raise
ValueError
,
"I/O operation on closed file"
raise
ValueError
,
"I/O operation on closed file"
if
self
.
buflist
:
if
self
.
buflist
:
self
.
buf
+=
EMPTYSTRING
.
join
(
self
.
buflist
)
self
.
buf
+=
''
.
join
(
self
.
buflist
)
self
.
buflist
=
[]
self
.
buflist
=
[]
if
mode
==
1
:
if
mode
==
1
:
pos
+=
self
.
pos
pos
+=
self
.
pos
...
@@ -78,7 +76,7 @@ class StringIO:
...
@@ -78,7 +76,7 @@ class StringIO:
if
self
.
closed
:
if
self
.
closed
:
raise
ValueError
,
"I/O operation on closed file"
raise
ValueError
,
"I/O operation on closed file"
if
self
.
buflist
:
if
self
.
buflist
:
self
.
buf
+=
EMPTYSTRING
.
join
(
self
.
buflist
)
self
.
buf
+=
''
.
join
(
self
.
buflist
)
self
.
buflist
=
[]
self
.
buflist
=
[]
if
n
<
0
:
if
n
<
0
:
newpos
=
self
.
len
newpos
=
self
.
len
...
@@ -92,7 +90,7 @@ class StringIO:
...
@@ -92,7 +90,7 @@ class StringIO:
if
self
.
closed
:
if
self
.
closed
:
raise
ValueError
,
"I/O operation on closed file"
raise
ValueError
,
"I/O operation on closed file"
if
self
.
buflist
:
if
self
.
buflist
:
self
.
buf
+=
EMPTYSTRING
.
join
(
self
.
buflist
)
self
.
buf
+=
''
.
join
(
self
.
buflist
)
self
.
buflist
=
[]
self
.
buflist
=
[]
i
=
self
.
buf
.
find
(
'
\
n
'
,
self
.
pos
)
i
=
self
.
buf
.
find
(
'
\
n
'
,
self
.
pos
)
if
i
<
0
:
if
i
<
0
:
...
@@ -139,7 +137,7 @@ class StringIO:
...
@@ -139,7 +137,7 @@ class StringIO:
newpos
=
self
.
pos
+
len
(
s
)
newpos
=
self
.
pos
+
len
(
s
)
if
self
.
pos
<
self
.
len
:
if
self
.
pos
<
self
.
len
:
if
self
.
buflist
:
if
self
.
buflist
:
self
.
buf
+=
EMPTYSTRING
.
join
(
self
.
buflist
)
self
.
buf
+=
''
.
join
(
self
.
buflist
)
self
.
buflist
=
[]
self
.
buflist
=
[]
self
.
buflist
=
[
self
.
buf
[:
self
.
pos
],
s
,
self
.
buf
[
newpos
:]]
self
.
buflist
=
[
self
.
buf
[:
self
.
pos
],
s
,
self
.
buf
[
newpos
:]]
self
.
buf
=
''
self
.
buf
=
''
...
@@ -151,7 +149,7 @@ class StringIO:
...
@@ -151,7 +149,7 @@ class StringIO:
self
.
pos
=
newpos
self
.
pos
=
newpos
def
writelines
(
self
,
list
):
def
writelines
(
self
,
list
):
self
.
write
(
EMPTYSTRING
.
join
(
list
))
self
.
write
(
''
.
join
(
list
))
def
flush
(
self
):
def
flush
(
self
):
if
self
.
closed
:
if
self
.
closed
:
...
@@ -159,7 +157,7 @@ class StringIO:
...
@@ -159,7 +157,7 @@ class StringIO:
def
getvalue
(
self
):
def
getvalue
(
self
):
if
self
.
buflist
:
if
self
.
buflist
:
self
.
buf
+=
EMPTYSTRING
.
join
(
self
.
buflist
)
self
.
buf
+=
''
.
join
(
self
.
buflist
)
self
.
buflist
=
[]
self
.
buflist
=
[]
return
self
.
buf
return
self
.
buf
...
...
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