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

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

Issue 12382022: Speeding up Node.nodes.addAll (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 9 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 | « sdk/lib/html/dartium/html_dartium.dart ('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 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
62 void add(Node value) { 62 void add(Node value) {
63 _this.$dom_appendChild(value); 63 _this.$dom_appendChild(value);
64 } 64 }
65 65
66 void addLast(Node value) { 66 void addLast(Node value) {
67 _this.$dom_appendChild(value); 67 _this.$dom_appendChild(value);
68 } 68 }
69 69
70 70
71 void addAll(Iterable<Node> iterable) { 71 void addAll(Iterable<Node> iterable) {
72 if (iterable is _ChildNodeListLazy) { 72 if (iterable is _ChildNodeListLazy) {
Siggi Cherem (dart-lang) 2013/02/28 19:43:32 is it worth doing this also for other types like L
blois 2013/02/28 20:45:58 The optimized loop requires that it be a browser n
Siggi Cherem (dart-lang) 2013/03/01 00:05:28 I see, thanks! - somehow the [0] below didn't sink
73 iterable = new List.from(iterable); 73 if (iterable._this != _this) {
sra1 2013/03/01 01:17:59 if (!identical(iterable._this, _this))
74 // Optimized route for copying between nodes.
75 for (var i = 0, len = iterable.length; i < len; ++i) {
76 _this.$dom_appendChild(iterable[0]);
sra1 2013/03/01 01:17:59 iterable.first should be slightly faster.
sra1 2013/03/01 01:28:46 or, better, iterable._this.$dom_firstChild
77 }
78 }
79 return;
74 } 80 }
75 for (Node node in iterable) { 81 for (Node node in iterable) {
76 _this.$dom_appendChild(node); 82 _this.$dom_appendChild(node);
77 } 83 }
78 } 84 }
79 85
80 Node removeLast() { 86 Node removeLast() {
81 final result = last; 87 final result = last;
82 if (result != null) { 88 if (result != null) {
83 _this.$dom_removeChild(result); 89 _this.$dom_removeChild(result);
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after
280 final Node parent = this.parentNode; 286 final Node parent = this.parentNode;
281 parent.$dom_replaceChild(otherNode, this); 287 parent.$dom_replaceChild(otherNode, this);
282 } catch (e) { 288 } catch (e) {
283 289
284 }; 290 };
285 return this; 291 return this;
286 } 292 }
287 293
288 $!MEMBERS 294 $!MEMBERS
289 } 295 }
OLDNEW
« no previous file with comments | « sdk/lib/html/dartium/html_dartium.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698