| OLD | NEW |
| 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 /** | 5 /** |
| 6 * The StringBuffer class is useful for concatenating strings | 6 * The StringBuffer class is useful for concatenating strings |
| 7 * efficiently. Only on a call to [toString] are the strings | 7 * efficiently. Only on a call to [toString] are the strings |
| 8 * concatenated to a single String. | 8 * concatenated to a single String. |
| 9 */ | 9 */ |
| 10 abstract class StringBuffer { | 10 abstract class StringBuffer { |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 110 _length = 0; | 110 _length = 0; |
| 111 return this; | 111 return this; |
| 112 } | 112 } |
| 113 | 113 |
| 114 /** | 114 /** |
| 115 * Returns the contents of buffer as a concatenated string. | 115 * Returns the contents of buffer as a concatenated string. |
| 116 */ | 116 */ |
| 117 String toString() { | 117 String toString() { |
| 118 if (_buffer.length === 0) return ""; | 118 if (_buffer.length === 0) return ""; |
| 119 if (_buffer.length === 1) return _buffer[0]; | 119 if (_buffer.length === 1) return _buffer[0]; |
| 120 String result = StringImplementation.concatAll(_buffer); | 120 String result = _StringImpl.concatAll(_buffer); |
| 121 _buffer.clear(); | 121 _buffer.clear(); |
| 122 _buffer.add(result); | 122 _buffer.add(result); |
| 123 // Since we track the length at each add operation, there is no | 123 // Since we track the length at each add operation, there is no |
| 124 // need to update it in this function. | 124 // need to update it in this function. |
| 125 return result; | 125 return result; |
| 126 } | 126 } |
| 127 | 127 |
| 128 List<String> _buffer; | 128 List<String> _buffer; |
| 129 int _length; | 129 int _length; |
| 130 } | 130 } |
| OLD | NEW |