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

Side by Side Diff: pkg/front_end/lib/src/incremental/file_state.dart

Issue 2980523003: Use precomputed uriBytes while computing cycle signature. (Closed)
Patch Set: Created 3 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
« no previous file with comments | « no previous file | pkg/front_end/lib/src/incremental_kernel_generator_impl.dart » ('j') | 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) 2017, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2017, 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 import 'dart:async'; 5 import 'dart:async';
6 import 'dart:convert';
6 import 'dart:typed_data'; 7 import 'dart:typed_data';
7 8
8 import 'package:convert/convert.dart'; 9 import 'package:convert/convert.dart';
9 import 'package:crypto/crypto.dart'; 10 import 'package:crypto/crypto.dart';
10 import 'package:front_end/file_system.dart'; 11 import 'package:front_end/file_system.dart';
11 import 'package:front_end/src/base/resolve_relative_uri.dart'; 12 import 'package:front_end/src/base/resolve_relative_uri.dart';
12 import 'package:front_end/src/dependency_walker.dart' as graph; 13 import 'package:front_end/src/dependency_walker.dart' as graph;
13 import 'package:front_end/src/fasta/translate_uri.dart'; 14 import 'package:front_end/src/fasta/translate_uri.dart';
14 import 'package:front_end/src/incremental/byte_store.dart'; 15 import 'package:front_end/src/incremental/byte_store.dart';
15 import 'package:front_end/src/incremental/format.dart'; 16 import 'package:front_end/src/incremental/format.dart';
(...skipping 10 matching lines...) Expand all
26 /// 27 ///
27 /// The properties are not guaranteed to represent the most recent state 28 /// The properties are not guaranteed to represent the most recent state
28 /// of the file system. To update the file to the most recent state, [refresh] 29 /// of the file system. To update the file to the most recent state, [refresh]
29 /// should be called. 30 /// should be called.
30 class FileState { 31 class FileState {
31 final FileSystemState _fsState; 32 final FileSystemState _fsState;
32 33
33 /// The absolute URI of the file. 34 /// The absolute URI of the file.
34 final Uri uri; 35 final Uri uri;
35 36
37 /// The UTF8 bytes of the [uri].
38 final List<int> uriBytes;
39
36 /// The resolved URI of the file in the file system. 40 /// The resolved URI of the file in the file system.
37 final Uri fileUri; 41 final Uri fileUri;
38 42
39 bool _exists; 43 bool _exists;
40 List<int> _content; 44 List<int> _content;
41 List<int> _contentHash; 45 List<int> _contentHash;
42 bool _hasMixinApplication; 46 bool _hasMixinApplication;
43 List<int> _apiSignature; 47 List<int> _apiSignature;
44 48
45 List<NamespaceExport> _exports; 49 List<NamespaceExport> _exports;
46 List<FileState> _importedLibraries; 50 List<FileState> _importedLibraries;
47 List<FileState> _exportedLibraries; 51 List<FileState> _exportedLibraries;
48 List<FileState> _partFiles; 52 List<FileState> _partFiles;
49 53
50 Set<FileState> _directReferencedFiles = new Set<FileState>(); 54 Set<FileState> _directReferencedFiles = new Set<FileState>();
51 List<FileState> _directReferencedLibraries = <FileState>[]; 55 List<FileState> _directReferencedLibraries = <FileState>[];
52 Set<FileState> _transitiveFiles; 56 Set<FileState> _transitiveFiles;
53 57
54 /// This flag is set to `true` during the mark phase of garbage collection 58 /// This flag is set to `true` during the mark phase of garbage collection
55 /// and set back to `false` for survived instances. 59 /// and set back to `false` for survived instances.
56 bool _gcMarked = false; 60 bool _gcMarked = false;
57 61
58 FileState._(this._fsState, this.uri, this.fileUri); 62 FileState._(this._fsState, this.uri, this.fileUri)
63 : uriBytes = UTF8.encode(uri.toString());
59 64
60 /// The MD5 signature of the file API as a byte array. 65 /// The MD5 signature of the file API as a byte array.
61 /// It depends on all non-comment tokens outside the block bodies. 66 /// It depends on all non-comment tokens outside the block bodies.
62 List<int> get apiSignature => _apiSignature; 67 List<int> get apiSignature => _apiSignature;
63 68
64 /// The content of the file. 69 /// The content of the file.
65 List<int> get content => _content; 70 List<int> get content => _content;
66 71
67 /// The MD5 hash of the [content]. 72 /// The MD5 hash of the [content].
68 List<int> get contentHash => _contentHash; 73 List<int> get contentHash => _contentHash;
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
101 List<LibraryCycle> get topologicalOrder { 106 List<LibraryCycle> get topologicalOrder {
102 var libraryWalker = new _LibraryWalker(); 107 var libraryWalker = new _LibraryWalker();
103 libraryWalker.walk(libraryWalker.getNode(this)); 108 libraryWalker.walk(libraryWalker.getNode(this));
104 return libraryWalker.topologicallySortedCycles; 109 return libraryWalker.topologicallySortedCycles;
105 } 110 }
106 111
107 /// Return the set of transitive files - the file itself and all of the 112 /// Return the set of transitive files - the file itself and all of the
108 /// directly or indirectly referenced files. 113 /// directly or indirectly referenced files.
109 Set<FileState> get transitiveFiles { 114 Set<FileState> get transitiveFiles {
110 if (_transitiveFiles == null) { 115 if (_transitiveFiles == null) {
111 _transitiveFiles = new Set<FileState>(); 116 _transitiveFiles = new Set<FileState>.identity();
112 117
113 void appendReferenced(FileState file) { 118 void appendReferenced(FileState file) {
114 if (_transitiveFiles.add(file)) { 119 if (_transitiveFiles.add(file)) {
115 file._directReferencedFiles.forEach(appendReferenced); 120 file._directReferencedFiles.forEach(appendReferenced);
116 } 121 }
117 } 122 }
118 123
119 appendReferenced(this); 124 appendReferenced(this);
120 } 125 }
121 return _transitiveFiles; 126 return _transitiveFiles;
(...skipping 387 matching lines...) Expand 10 before | Expand all | Expand 10 after
509 cycle.libraries.add(node.file); 514 cycle.libraries.add(node.file);
510 fileToCycleMap[node.file] = cycle; 515 fileToCycleMap[node.file] = cycle;
511 } 516 }
512 topologicallySortedCycles.add(cycle); 517 topologicallySortedCycles.add(cycle);
513 } 518 }
514 519
515 _LibraryNode getNode(FileState file) { 520 _LibraryNode getNode(FileState file) {
516 return nodesOfFiles.putIfAbsent(file, () => new _LibraryNode(this, file)); 521 return nodesOfFiles.putIfAbsent(file, () => new _LibraryNode(this, file));
517 } 522 }
518 } 523 }
OLDNEW
« no previous file with comments | « no previous file | pkg/front_end/lib/src/incremental_kernel_generator_impl.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698