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

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

Issue 368193004: Dart2js Avoid file-names of deferred .part-files from getting too long. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 5 months 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, 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 library deferred_load; 5 library deferred_load;
6 6
7 import 'dart2jslib.dart' show 7 import 'dart2jslib.dart' show
8 Backend, 8 Backend,
9 Compiler, 9 Compiler,
10 CompilerTask, 10 CompilerTask,
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
50 LibraryDependency, 50 LibraryDependency,
51 LiteralString, 51 LiteralString,
52 LiteralDartString; 52 LiteralDartString;
53 53
54 import 'tree/tree.dart' as ast; 54 import 'tree/tree.dart' as ast;
55 55
56 import 'resolution/resolution.dart' show 56 import 'resolution/resolution.dart' show
57 TreeElements, 57 TreeElements,
58 AnalyzableElementX; 58 AnalyzableElementX;
59 59
60 import "dart:math" show min;
61
60 /// A "hunk" of the program that will be loaded whenever one of its [imports] 62 /// A "hunk" of the program that will be loaded whenever one of its [imports]
61 /// are loaded. 63 /// are loaded.
62 /// 64 ///
63 /// Elements that are only used in one deferred import, is in an OutputUnit with 65 /// Elements that are only used in one deferred import, is in an OutputUnit with
64 /// the deferred import as single element in the [imports] set. 66 /// the deferred import as single element in the [imports] set.
65 /// 67 ///
66 /// Whenever a deferred Element is shared between several deferred imports it is 68 /// Whenever a deferred Element is shared between several deferred imports it is
67 /// in an output unit with those imports in the [imports] Set. 69 /// in an output unit with those imports in the [imports] Set.
68 /// 70 ///
69 /// OutputUnits are equal if their [imports] are equal. 71 /// OutputUnits are equal if their [imports] are equal.
(...skipping 487 matching lines...) Expand 10 before | Expand all | Expand 10 after
557 } 559 }
558 assert(result != null); 560 assert(result != null);
559 importDeferName[import] = makeUnique(result, usedImportNames);; 561 importDeferName[import] = makeUnique(result, usedImportNames);;
560 } 562 }
561 563
562 Set<String> usedOutputUnitNames = new Set<String>(); 564 Set<String> usedOutputUnitNames = new Set<String>();
563 Map<OutputUnit, String> generatedNames = new Map<OutputUnit, String>(); 565 Map<OutputUnit, String> generatedNames = new Map<OutputUnit, String>();
564 566
565 void computeOutputUnitName(OutputUnit outputUnit) { 567 void computeOutputUnitName(OutputUnit outputUnit) {
566 if (generatedNames[outputUnit] != null) return; 568 if (generatedNames[outputUnit] != null) return;
567 String suggestedName = outputUnit.imports.map((import) { 569 Iterable<String> importNames = outputUnit.imports.map((import) {
568 return importDeferName[import]; 570 return importDeferName[import];
569 }).join('_'); 571 });
572 String suggestedName = importNames.join('_');
Alan Knight 2014/07/07 20:08:07 Is this going to run into potential problems with
sigurdm 2014/07/08 07:19:58 We take care of the uniqueness a few lines further
573 // Avoid the name getting too long.
574 // Try to abbreviate the prefix-names
575 if (suggestedName.length > 15) {
576 suggestedName = importNames.map((name) {
577 return name.substring(0, min(2, name.length));
578 }).join('_');
579 }
580 // If this is still too long, truncate the whole name.
581 if (suggestedName.length > 15) {
582 suggestedName = suggestedName.substring(0, 15);
583 }
570 outputUnit.name = makeUnique(suggestedName, usedOutputUnitNames); 584 outputUnit.name = makeUnique(suggestedName, usedOutputUnitNames);
571 generatedNames[outputUnit] = outputUnit.name; 585 generatedNames[outputUnit] = outputUnit.name;
572 } 586 }
573 587
574 for (Import import in _allDeferredImports.keys) { 588 for (Import import in _allDeferredImports.keys) {
575 computeImportDeferName(import); 589 computeImportDeferName(import);
576 } 590 }
577 591
578 for (OutputUnit outputUnit in allOutputUnits) { 592 for (OutputUnit outputUnit in allOutputUnits) {
579 computeOutputUnitName(outputUnit); 593 computeOutputUnitName(outputUnit);
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after
796 Element maybePrefix = elements[identifier]; 810 Element maybePrefix = elements[identifier];
797 if (maybePrefix != null && maybePrefix.isPrefix) { 811 if (maybePrefix != null && maybePrefix.isPrefix) {
798 PrefixElement prefixElement = maybePrefix; 812 PrefixElement prefixElement = maybePrefix;
799 if (prefixElement.isDeferred) { 813 if (prefixElement.isDeferred) {
800 return prefixElement; 814 return prefixElement;
801 } 815 }
802 } 816 }
803 return null; 817 return null;
804 } 818 }
805 } 819 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698