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

Side by Side Diff: compiler/lib/implementation/string_buffer.dart

Issue 8321024: Clean up (most) uses of Array. Still more to come in the VM corelib code base. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: '' Created 9 years, 2 months 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 | « compiler/lib/implementation/string_base.dart ('k') | corelib/src/implementation/array.dart » ('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 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
53 * Returns [this]. 53 * Returns [this].
54 */ 54 */
55 StringBuffer addCharCode(int charCode) { 55 StringBuffer addCharCode(int charCode) {
56 return add(new String.fromCharCodes([charCode])); 56 return add(new String.fromCharCodes([charCode]));
57 } 57 }
58 58
59 /** 59 /**
60 * Clears the string buffer. Returns [this]. 60 * Clears the string buffer. Returns [this].
61 */ 61 */
62 StringBuffer clear() { 62 StringBuffer clear() {
63 _buffer = new Array<String>(); 63 _buffer = new List<String>();
64 _length = 0; 64 _length = 0;
65 return this; 65 return this;
66 } 66 }
67 67
68 /** 68 /**
69 * Returns the contents of buffer as a concatenated string. 69 * Returns the contents of buffer as a concatenated string.
70 */ 70 */
71 String toString() { 71 String toString() {
72 if (_buffer.length == 0) return ""; 72 if (_buffer.length == 0) return "";
73 if (_buffer.length == 1) return _buffer[0]; 73 if (_buffer.length == 1) return _buffer[0];
74 String result = StringBase.concatAll(_buffer); 74 String result = StringBase.concatAll(_buffer);
75 _buffer.clear(); 75 _buffer.clear();
76 _buffer.add(result); 76 _buffer.add(result);
77 // Since we track the length at each add operation, there is no 77 // Since we track the length at each add operation, there is no
78 // need to update it in this function. 78 // need to update it in this function.
79 return result; 79 return result;
80 } 80 }
81 81
82 Array<String> _buffer; 82 List<String> _buffer;
83 int _length; 83 int _length;
84 } 84 }
OLDNEW
« no previous file with comments | « compiler/lib/implementation/string_base.dart ('k') | corelib/src/implementation/array.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698