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

Commit

Permalink
perf(cd): fewer string concatenations (10% improvement)
Browse files Browse the repository at this point in the history
  • Loading branch information
mhevery authored and jbdeboer committed Jul 12, 2014
1 parent b74d568 commit a652680
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions lib/change_detection/watch_group.dart
Original file line number Diff line number Diff line change
Expand Up @@ -672,10 +672,11 @@ abstract class _ArgHandler extends _Handler {
}

class _PositionalArgHandler extends _ArgHandler {
static final List<String> _ARGS = new List.generate(20, (index) => 'arg[$index]');
final int index;
_PositionalArgHandler(WatchGroup watchGrp, _EvalWatchRecord record, int index)
: this.index = index,
super(watchGrp, 'arg[$index]', record);
super(watchGrp, _ARGS[index], record);

void acceptValue(object) {
watchRecord.dirtyArgs = true;
Expand All @@ -684,11 +685,17 @@ class _PositionalArgHandler extends _ArgHandler {
}

class _NamedArgHandler extends _ArgHandler {
static final Map<Symbol, String> _NAMED_ARG = new HashMap<Symbol, String>();
static String _GET_NAMED_ARG(Symbol symbol) {
String name = _NAMED_ARG[symbol];
if (name == null) name = _NAMED_ARG[symbol] = 'namedArg[$name]';
return name;
}
final Symbol name;

_NamedArgHandler(WatchGroup watchGrp, _EvalWatchRecord record, Symbol name)
: this.name = name,
super(watchGrp, 'namedArg[$name]', record);
super(watchGrp, _GET_NAMED_ARG(name), record);

void acceptValue(object) {
if (watchRecord.namedArgs == null) {
Expand Down

0 comments on commit a652680

Please sign in to comment.