Chromium Code Reviews| 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 class StringBufferImpl implements StringBuffer { | 10 class StringBufferImpl implements StringBuffer { |
| (...skipping 24 matching lines...) Expand all Loading... | |
| 35 if (str === null || str.isEmpty()) return this; | 35 if (str === null || str.isEmpty()) return this; |
| 36 _buffer.add(str); | 36 _buffer.add(str); |
| 37 _length += str.length; | 37 _length += str.length; |
| 38 return this; | 38 return this; |
| 39 } | 39 } |
| 40 | 40 |
| 41 /** | 41 /** |
| 42 * Adds all items in [objects] to the buffer. Returns [this]. | 42 * Adds all items in [objects] to the buffer. Returns [this]. |
| 43 */ | 43 */ |
| 44 StringBuffer addAll(Collection<Object> objects) { | 44 StringBuffer addAll(Collection<Object> objects) { |
| 45 if (objects == null) { | |
|
codefu
2011/12/14 16:12:13
Same optimization error; co19/LibTest/core/StringB
| |
| 46 throw const NullPointerException(); | |
| 47 } | |
| 45 for (Object obj in objects) { | 48 for (Object obj in objects) { |
| 46 add(obj); | 49 add(obj); |
| 47 } | 50 } |
| 48 return this; | 51 return this; |
| 49 } | 52 } |
| 50 | 53 |
| 51 /** | 54 /** |
| 52 * Adds the string representation of [charCode] to the buffer. | 55 * Adds the string representation of [charCode] to the buffer. |
| 53 * Returns [this]. | 56 * Returns [this]. |
| 54 */ | 57 */ |
| (...skipping 20 matching lines...) Expand all Loading... | |
| 75 _buffer.clear(); | 78 _buffer.clear(); |
| 76 _buffer.add(result); | 79 _buffer.add(result); |
| 77 // Since we track the length at each add operation, there is no | 80 // Since we track the length at each add operation, there is no |
| 78 // need to update it in this function. | 81 // need to update it in this function. |
| 79 return result; | 82 return result; |
| 80 } | 83 } |
| 81 | 84 |
| 82 List<String> _buffer; | 85 List<String> _buffer; |
| 83 int _length; | 86 int _length; |
| 84 } | 87 } |
| OLD | NEW |