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

Unified Diff: editor/util/plugins/com.google.dart.java2dart/resources/ast_include.dart

Issue 107833002: New analyzer snapshot. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years 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 side-by-side diff with in-line comments
Download patch
Index: editor/util/plugins/com.google.dart.java2dart/resources/ast_include.dart
diff --git a/editor/util/plugins/com.google.dart.java2dart/resources/ast_include.dart b/editor/util/plugins/com.google.dart.java2dart/resources/ast_include.dart
index 69280926b398b9a7e161894cc25e7fdb563d1f4e..2d291a35a0ee25431f40440c9b2f73a7ff5bce9e 100644
--- a/editor/util/plugins/com.google.dart.java2dart/resources/ast_include.dart
+++ b/editor/util/plugins/com.google.dart.java2dart/resources/ast_include.dart
@@ -36,8 +36,9 @@ class NodeList<E extends ASTNode> extends Object with ListMixin<E> {
* @param visitor the visitor to be used to visit the elements of this list
*/
accept(ASTVisitor visitor) {
- for (E element in _elements) {
- element.accept(visitor);
+ var length = _elements.length;
+ for (var i = 0; i < length; i++) {
+ _elements[i].accept(visitor);
}
}
void add(E node) {
@@ -52,25 +53,15 @@ class NodeList<E extends ASTNode> extends Object with ListMixin<E> {
if (length == 0) {
_elements = <E> [node];
} else {
- List<E> newElements = new List<E>(length + 1);
- JavaSystem.arraycopy(_elements, 0, newElements, 0, index);
- newElements[index] = node;
- JavaSystem.arraycopy(_elements, index, newElements, index + 1, length - index);
- _elements = newElements;
+ _elements.insert(index, node);
}
}
bool addAll(Iterable<E> nodes) {
if (nodes != null && !nodes.isEmpty) {
- int oldCount = _elements.length;
- int newCount = nodes.length;
- List<E> newElements = new List<E>(oldCount + newCount);
- JavaSystem.arraycopy(_elements, 0, newElements, 0, oldCount);
- int index = oldCount;
+ _elements.addAll(nodes);
for (E node in nodes) {
owner.becomeParentOf(node);
- newElements[index++] = node;
}
- _elements = newElements;
return true;
}
return false;
@@ -115,17 +106,13 @@ class NodeList<E extends ASTNode> extends Object with ListMixin<E> {
_elements = ASTNode.EMPTY_ARRAY;
return removedNode;
}
- List<E> newElements = new List<E>(length - 1);
- JavaSystem.arraycopy(_elements, 0, newElements, 0, index);
- JavaSystem.arraycopy(_elements, index + 1, newElements, index, length - index - 1);
- _elements = newElements;
+ _elements.removeAt(index);
return removedNode;
}
void operator[]=(int index, E node) {
if (index < 0 || index >= _elements.length) {
throw new RangeError("Index: ${index}, Size: ${_elements.length}");
}
- _elements[index] as E;
owner.becomeParentOf(node);
_elements[index] = node;
}

Powered by Google App Engine
This is Rietveld 408576698