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

Side by Side Diff: tools/dom/templates/html/impl/impl_Node.darttemplate

Issue 216933005: Speeding up ElementList.clear & NodeList.clear. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Element now matches Node Created 6 years, 8 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 | « tools/dom/templates/html/impl/impl_Element.darttemplate ('k') | no next file » | 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) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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 part of $LIBRARYNAME; 5 part of $LIBRARYNAME;
6 6
7 /** 7 /**
8 * Lazy implementation of the child nodes of an element that does not request 8 * Lazy implementation of the child nodes of an element that does not request
9 * the actual child nodes of an element until strictly necessary greatly 9 * the actual child nodes of an element until strictly necessary greatly
10 * improving performance for the typical cases where it is not required. 10 * improving performance for the typical cases where it is not required.
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
131 131
132 void removeWhere(bool test(Node node)) { 132 void removeWhere(bool test(Node node)) {
133 _filter(test, true); 133 _filter(test, true);
134 } 134 }
135 135
136 void retainWhere(bool test(Node node)) { 136 void retainWhere(bool test(Node node)) {
137 _filter(test, false); 137 _filter(test, false);
138 } 138 }
139 139
140 void clear() { 140 void clear() {
141 _this.text = ''; 141 _this._clearChildren();
142 } 142 }
143 143
144 void operator []=(int index, Node value) { 144 void operator []=(int index, Node value) {
145 _this._replaceChild(value, this[index]); 145 _this._replaceChild(value, this[index]);
146 } 146 }
147 147
148 Iterator<Node> get iterator => _this.childNodes.iterator; 148 Iterator<Node> get iterator => _this.childNodes.iterator;
149 149
150 // From List<Node>: 150 // From List<Node>:
151 151
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
252 for (var i = 0, len = otherList.length; i < len; ++i) { 252 for (var i = 0, len = otherList.length; i < len; ++i) {
253 this.insertBefore(otherList._this.firstChild, refChild); 253 this.insertBefore(otherList._this.firstChild, refChild);
254 } 254 }
255 } else { 255 } else {
256 for (var node in newNodes) { 256 for (var node in newNodes) {
257 this.insertBefore(node, refChild); 257 this.insertBefore(node, refChild);
258 } 258 }
259 } 259 }
260 } 260 }
261 261
262 void _clearChildren() {
263 while (firstChild != null) {
264 _removeChild(firstChild);
265 }
266 }
267
262 /** 268 /**
263 * Print out a String representation of this Node. 269 * Print out a String representation of this Node.
264 */ 270 */
265 String toString() => nodeValue == null ? super.toString() : nodeValue; 271 String toString() => nodeValue == null ? super.toString() : nodeValue;
266 $!MEMBERS 272 $!MEMBERS
267 } 273 }
OLDNEW
« no previous file with comments | « tools/dom/templates/html/impl/impl_Element.darttemplate ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698