Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(158)

Side by Side Diff: runtime/lib/string_buffer.dart

Issue 8510066: Fix String.trim implementation (follow spec). (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: '' Created 9 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « runtime/lib/string.dart ('k') | tests/co19/co19-compiler.status » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 14 matching lines...) Expand all
25 25
26 bool isEmpty() { 26 bool isEmpty() {
27 return _length === 0; 27 return _length === 0;
28 } 28 }
29 29
30 /** 30 /**
31 * Adds [obj] to the buffer. Returns [this]. 31 * Adds [obj] to the buffer. Returns [this].
32 */ 32 */
33 StringBuffer add(Object obj) { 33 StringBuffer add(Object obj) {
34 String str = obj.toString(); 34 String str = obj.toString();
35 if (str === null || str.isEmpty()) return; 35 if (str === null || str.isEmpty()) {
36 return this;
37 }
36 _buffer.add(str); 38 _buffer.add(str);
37 _length += str.length; 39 _length += str.length;
38 return this; 40 return this;
39 } 41 }
40 42
41 /** 43 /**
42 * Adds all items in [objects] to the buffer. Returns [this]. 44 * Adds all items in [objects] to the buffer. Returns [this].
43 */ 45 */
44 StringBuffer addAll(Collection<Object> objects) { 46 StringBuffer addAll(Collection<Object> objects) {
45 for (Object obj in objects) { 47 for (Object obj in objects) {
(...skipping 29 matching lines...) Expand all
75 _buffer.clear(); 77 _buffer.clear();
76 _buffer.add(result); 78 _buffer.add(result);
77 // Since we track the length at each add operation, there is no 79 // Since we track the length at each add operation, there is no
78 // need to update it in this function. 80 // need to update it in this function.
79 return result; 81 return result;
80 } 82 }
81 83
82 List<String> _buffer; 84 List<String> _buffer;
83 int _length; 85 int _length;
84 } 86 }
OLDNEW
« no previous file with comments | « runtime/lib/string.dart ('k') | tests/co19/co19-compiler.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698