diff --git a/CHANGELOG.md b/CHANGELOG.md index 4297dea9fa..7dee9e7847 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ * added a new `--footer-text` command-line option, to allow adding additional text in the package name and copyright section of the footer +* Reduced stack depth by not recomputing findCanonicalLibraryFor (#1381) ## 0.10.0 diff --git a/dartdoc.iml b/dartdoc.iml index 0a3f899376..23061822ae 100644 --- a/dartdoc.iml +++ b/dartdoc.iml @@ -1,6 +1,6 @@ - + @@ -33,7 +33,7 @@ - + \ No newline at end of file diff --git a/lib/src/html/html_generator.dart b/lib/src/html/html_generator.dart index 5cbae0767b..37e5118818 100644 --- a/lib/src/html/html_generator.dart +++ b/lib/src/html/html_generator.dart @@ -46,7 +46,8 @@ class HtmlGenerator extends Generator { static Future create( {HtmlGeneratorOptions options, List headers, - List footers, List footerTexts}) async { + List footers, + List footerTexts}) async { var templates = await Templates.create( headerPaths: headers, footerPaths: footers, diff --git a/lib/src/model.dart b/lib/src/model.dart index 56fff26309..ad2708e8d2 100644 --- a/lib/src/model.dart +++ b/lib/src/model.dart @@ -2796,16 +2796,25 @@ class Package implements Nameable, Documentable { @override String toString() => isSdk ? 'SDK' : 'Package $name'; + final Map _canonicalLibraryFor = new Map(); + /// Tries to find a top level library that references this element. Library findCanonicalLibraryFor(Element e) { + assert(allLibrariesAdded); + + if (_canonicalLibraryFor.containsKey(e)) { + return _canonicalLibraryFor[e]; + } + _canonicalLibraryFor[e] = null; for (Library library in libraries) { if (library.modelElementsMap.containsKey(e)) { if (library.modelElementsMap[e].isCanonical) { - return library; + _canonicalLibraryFor[e] = library; + break; } } } - return null; + return _canonicalLibraryFor[e]; } /// Tries to find a canonical ModelElement for this element.