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

Commit a652680

Browse files
mheveryjbdeboer
authored andcommitted
perf(cd): fewer string concatenations (10% improvement)
1 parent b74d568 commit a652680

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

lib/change_detection/watch_group.dart

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -672,10 +672,11 @@ abstract class _ArgHandler extends _Handler {
672672
}
673673

674674
class _PositionalArgHandler extends _ArgHandler {
675+
static final List<String> _ARGS = new List.generate(20, (index) => 'arg[$index]');
675676
final int index;
676677
_PositionalArgHandler(WatchGroup watchGrp, _EvalWatchRecord record, int index)
677678
: this.index = index,
678-
super(watchGrp, 'arg[$index]', record);
679+
super(watchGrp, _ARGS[index], record);
679680

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

686687
class _NamedArgHandler extends _ArgHandler {
688+
static final Map<Symbol, String> _NAMED_ARG = new HashMap<Symbol, String>();
689+
static String _GET_NAMED_ARG(Symbol symbol) {
690+
String name = _NAMED_ARG[symbol];
691+
if (name == null) name = _NAMED_ARG[symbol] = 'namedArg[$name]';
692+
return name;
693+
}
687694
final Symbol name;
688695

689696
_NamedArgHandler(WatchGroup watchGrp, _EvalWatchRecord record, Symbol name)
690697
: this.name = name,
691-
super(watchGrp, 'namedArg[$name]', record);
698+
super(watchGrp, _GET_NAMED_ARG(name), record);
692699

693700
void acceptValue(object) {
694701
if (watchRecord.namedArgs == null) {

0 commit comments

Comments
 (0)