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

Unified Diff: tools/dom/scripts/systemhtml.py

Issue 14619013: Explicitly implementing some DOM iterable APIs for performance (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 7 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « tests/html/node_test.dart ('k') | tools/dom/scripts/systemnative.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/dom/scripts/systemhtml.py
diff --git a/tools/dom/scripts/systemhtml.py b/tools/dom/scripts/systemhtml.py
index 6adefadaa43fa2ea993f07514c77903eb3893330..abc3ff360ed228dd8ecdee5bd8242f18b3e8934d 100644
--- a/tools/dom/scripts/systemhtml.py
+++ b/tools/dom/scripts/systemhtml.py
@@ -712,19 +712,22 @@ class Dart2JSBackend(HtmlDartGenerator):
'CustomIndexedSetter' in ext_attrs)
if has_indexed_getter:
+ indexed_getter = ('JS("%s", "#[#]", this, index)' %
+ self.SecureOutputType(element_type));
+ elif any(op.id == 'getItem' for op in self._interface.operations):
+ indexed_getter = 'this.getItem(index)'
+ elif any(op.id == 'item' for op in self._interface.operations):
+ indexed_getter = 'this.item(index)'
+
+ if indexed_getter:
self._members_emitter.Emit(
'\n'
- ' $TYPE operator[](int index) => '
- 'JS("$TYPE", "#[#]", this, index);\n',
- TYPE=self.SecureOutputType(element_type))
- else:
- if any(op.id == 'getItem' for op in self._interface.operations):
- indexed_getter = 'this.getItem(index)'
- elif any(op.id == 'item' for op in self._interface.operations):
- indexed_getter = 'this.item(index)'
- self._members_emitter.Emit(
- '\n'
- ' $TYPE operator[](int index) => $INDEXED_GETTER;\n',
+ ' $TYPE operator[](int index) {\n'
+ ' if (JS("bool", "# >>> 0 !== # || # >= #", index,\n'
+ ' index, index, length))\n'
+ ' throw new RangeError.range(index, 0, length);\n'
+ ' return $INDEXED_GETTER;\n'
+ ' }',
INDEXED_GETTER=indexed_getter,
TYPE=self.SecureOutputType(element_type))
« no previous file with comments | « tests/html/node_test.dart ('k') | tools/dom/scripts/systemnative.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698