Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(314)

Side by Side Diff: sdk/lib/_internal/compiler/implementation/dart_backend/backend.dart

Issue 11412086: Make 'where' lazy. (Closed) Base URL: https://dart.googlecode.com/svn/experimental/lib_v2/dart
Patch Set: FilteredIterable/Iterator -> WhereIterable/Iterator. Created 8 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 part of dart_backend; 5 part of dart_backend;
6 6
7 // TODO(ahe): This class is simply wrong. This backend should use 7 // TODO(ahe): This class is simply wrong. This backend should use
8 // elements when it can, not AST nodes. Perhaps a [Map<Element, 8 // elements when it can, not AST nodes. Perhaps a [Map<Element,
9 // TreeElements>] is what is needed. 9 // TreeElements>] is what is needed.
10 class ElementAst { 10 class ElementAst {
(...skipping 432 matching lines...) Expand 10 before | Expand all | Expand 10 after
443 final unparser = new EmitterUnparser(renames); 443 final unparser = new EmitterUnparser(renames);
444 emitCode(unparser, imports, topLevelNodes, memberNodes); 444 emitCode(unparser, imports, topLevelNodes, memberNodes);
445 compiler.assembledCode = unparser.result; 445 compiler.assembledCode = unparser.result;
446 446
447 // Output verbose info about size ratio of resulting bundle to all 447 // Output verbose info about size ratio of resulting bundle to all
448 // referenced non-platform sources. 448 // referenced non-platform sources.
449 logResultBundleSizeInfo(topLevelElements); 449 logResultBundleSizeInfo(topLevelElements);
450 } 450 }
451 451
452 void logResultBundleSizeInfo(Set<Element> topLevelElements) { 452 void logResultBundleSizeInfo(Set<Element> topLevelElements) {
453 Collection<LibraryElement> referencedLibraries = 453 Iterable<LibraryElement> referencedLibraries =
454 compiler.libraries.values.where(isUserLibrary); 454 compiler.libraries.values.where(isUserLibrary);
455 // Sum total size of scripts in each referenced library. 455 // Sum total size of scripts in each referenced library.
456 int nonPlatformSize = 0; 456 int nonPlatformSize = 0;
457 for (LibraryElement lib in referencedLibraries) { 457 for (LibraryElement lib in referencedLibraries) {
458 for (CompilationUnitElement compilationUnit in lib.compilationUnits) { 458 for (CompilationUnitElement compilationUnit in lib.compilationUnits) {
459 nonPlatformSize += compilationUnit.script.text.length; 459 nonPlatformSize += compilationUnit.script.text.length;
460 } 460 }
461 } 461 }
462 int percentage = compiler.assembledCode.length * 100 ~/ nonPlatformSize; 462 int percentage = compiler.assembledCode.length * 100 ~/ nonPlatformSize;
463 log('Total used non-platform files size: ${nonPlatformSize} bytes, ' 463 log('Total used non-platform files size: ${nonPlatformSize} bytes, '
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
555 } 555 }
556 556
557 compareElements(e0, e1) { 557 compareElements(e0, e1) {
558 int result = compareBy((e) => e.getLibrary().uri.toString())(e0, e1); 558 int result = compareBy((e) => e.getLibrary().uri.toString())(e0, e1);
559 if (result != 0) return result; 559 if (result != 0) return result;
560 return compareBy((e) => e.position().charOffset)(e0, e1); 560 return compareBy((e) => e.position().charOffset)(e0, e1);
561 } 561 }
562 562
563 List<Element> sortElements(Collection<Element> elements) => 563 List<Element> sortElements(Collection<Element> elements) =>
564 sorted(elements, compareElements); 564 sorted(elements, compareElements);
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698