mirror of
				https://github.com/python/cpython.git
				synced 2025-10-31 13:41:24 +00:00 
			
		
		
		
	Remove silly EMPTYSTRING global. Saves a global lookup.
This commit is contained in:
		
							parent
							
								
									b3acd3e4d3
								
							
						
					
					
						commit
						85d6edfc83
					
				
					 1 changed files with 6 additions and 8 deletions
				
			
		|  | @ -36,8 +36,6 @@ | ||||||
| 
 | 
 | ||||||
| __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 @@ def seek(self, pos, mode = 0): | ||||||
|         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 @@ def read(self, n = -1): | ||||||
|         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 @@ def readline(self, length=None): | ||||||
|         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 @@ def write(self, s): | ||||||
|         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 @@ def write(self, s): | ||||||
|         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 @@ def flush(self): | ||||||
| 
 | 
 | ||||||
|     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 | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Marc-André Lemburg
						Marc-André Lemburg