Skip to content
This repository has been archived by the owner on Feb 22, 2018. It is now read-only.

Commit

Permalink
chore(mock): Converting mock's Logger to use ListBase
Browse files Browse the repository at this point in the history
It was using noSuchMethod and mirrors, both of which have the potential to bloat dart2js code size. This change may not have any real-world impact given the number of other places which also hit mirrors and NSM, but it seems good to remove the gratuitous use of these APIs.
  • Loading branch information
blois authored and mhevery committed Dec 13, 2013
1 parent 9d19012 commit 0559068
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
11 changes: 9 additions & 2 deletions lib/mock/log.dart
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class LogAttrDirective implements NgAttachAware {
*
* expect(logger).toEqual(['foo', 'bar']);
*/
class Logger implements List {
class Logger extends ListBase {
final List tokens = [];

/**
Expand All @@ -48,5 +48,12 @@ class Logger implements List {
*/
String result() => tokens.join('; ');

noSuchMethod(Invocation invocation) => mirror.reflect(tokens).delegate(invocation);

int get length => tokens.length;

operator [](int index) => tokens[index];

void operator []=(int index, value) { tokens[index] = value; }

void set length(int newLength) { tokens.length = newLength; }
}
2 changes: 1 addition & 1 deletion lib/mock/module.dart
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
library angular.mock;

import 'dart:async' as dart_async;
import 'dart:collection' show ListBase;
import 'dart:convert' show JSON;
import 'dart:html';
import 'dart:mirrors' as mirror;
import 'package:angular/angular.dart';
import 'package:angular/utils.dart' as utils;
import 'package:js/js.dart' as js;
Expand Down

0 comments on commit 0559068

Please sign in to comment.