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

Commit

Permalink
feat(metadata extractor): Cache the fieldMetadataExtractor for greate…
Browse files Browse the repository at this point in the history
…r performance

Dartium tests run in 7.6s; down from 18.2s.
dart2js on Chrome runs in 2m instead of 3m
  • Loading branch information
jbdeboer committed Apr 1, 2014
1 parent 2f186e4 commit 63c229c
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions lib/core/registry_dynamic.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ library angular.core_dynamic;
import 'dart:mirrors';
import 'package:angular/core/module_internal.dart';

var _fieldMetadataCache = new Map<Type, Map<String, AttrFieldAnnotation>>();

This comment has been minimized.

Copy link
@vicb

vicb Apr 1, 2014

Contributor

What 5 LOCs only ? I was expecting more ;)

Great change!

You mentioned you've used a profiler ? If yes, could you please give more details ?


class DynamicMetadataExtractor implements MetadataExtractor {
final _fieldAnnotations = [
reflectType(NgAttr),
Expand Down Expand Up @@ -51,6 +53,10 @@ class DynamicMetadataExtractor implements MetadataExtractor {


Map<String, AttrFieldAnnotation> fieldMetadataExtractor(Type type) {
return _fieldMetadataCache.putIfAbsent(type, () => _fieldMetadataExtractor(type));
}

Map<String, AttrFieldAnnotation> _fieldMetadataExtractor(Type type) {
ClassMirror cm = reflectType(type);
final fields = <String, AttrFieldAnnotation>{};
cm.declarations.forEach((Symbol name, DeclarationMirror decl) {
Expand Down

0 comments on commit 63c229c

Please sign in to comment.