summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarc-André Lemburg <mal@egenix.com>2001-02-09 13:37:37 (GMT)
committerMarc-André Lemburg <mal@egenix.com>2001-02-09 13:37:37 (GMT)
commit85d6edfc83ddba764f9ff5c9960ddf336e11f1bb (patch)
treeb1d2edb557fddbf0129e2ef12c25ed8f9ddb4aa4
parentb3acd3e4d338ef41d50b86e9230646c510bb5c6a (diff)
downloadcpython-85d6edfc83ddba764f9ff5c9960ddf336e11f1bb.zip
cpython-85d6edfc83ddba764f9ff5c9960ddf336e11f1bb.tar.gz
cpython-85d6edfc83ddba764f9ff5c9960ddf336e11f1bb.tar.bz2
Remove silly EMPTYSTRING global. Saves a global lookup.
-rw-r--r--Lib/StringIO.py14
1 files changed, 6 insertions, 8 deletions
diff --git a/Lib/StringIO.py b/Lib/StringIO.py
index bc5e9e2..2aef3c3 100644
--- a/Lib/StringIO.py
+++ b/Lib/StringIO.py
@@ -36,8 +36,6 @@ except ImportError:
__all__ = ["StringIO"]
-EMPTYSTRING = ''
-
class StringIO:
def __init__(self, buf = ''):
self.buf = buf
@@ -61,7 +59,7 @@ class StringIO:
if self.closed:
raise ValueError, "I/O operation on closed file"
if self.buflist:
- self.buf += EMPTYSTRING.join(self.buflist)
+ self.buf += ''.join(self.buflist)
self.buflist = []
if mode == 1:
pos += self.pos
@@ -78,7 +76,7 @@ class StringIO:
if self.closed:
raise ValueError, "I/O operation on closed file"
if self.buflist:
- self.buf += EMPTYSTRING.join(self.buflist)
+ self.buf += ''.join(self.buflist)
self.buflist = []
if n < 0:
newpos = self.len
@@ -92,7 +90,7 @@ class StringIO:
if self.closed:
raise ValueError, "I/O operation on closed file"
if self.buflist:
- self.buf += EMPTYSTRING.join(self.buflist)
+ self.buf += ''.join(self.buflist)
self.buflist = []
i = self.buf.find('\n', self.pos)
if i < 0:
@@ -139,7 +137,7 @@ class StringIO:
newpos = self.pos + len(s)
if self.pos < self.len:
if self.buflist:
- self.buf += EMPTYSTRING.join(self.buflist)
+ self.buf += ''.join(self.buflist)
self.buflist = []
self.buflist = [self.buf[:self.pos], s, self.buf[newpos:]]
self.buf = ''
@@ -151,7 +149,7 @@ class StringIO:
self.pos = newpos
def writelines(self, list):
- self.write(EMPTYSTRING.join(list))
+ self.write(''.join(list))
def flush(self):
if self.closed:
@@ -159,7 +157,7 @@ class StringIO:
def getvalue(self):
if self.buflist:
- self.buf += EMPTYSTRING.join(self.buflist)
+ self.buf += ''.join(self.buflist)
self.buflist = []
return self.buf