Remove getBucketForCompilationSettings (#28088)

This commit is contained in:
Andy 2018-10-24 15:37:46 -07:00 committed by GitHub
parent 854f20e90f
commit e46c846ee6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -121,14 +121,6 @@ namespace ts {
const buckets = createMap<Map<DocumentRegistryEntry>>();
const getCanonicalFileName = createGetCanonicalFileName(!!useCaseSensitiveFileNames);
function getBucketForCompilationSettings(key: DocumentRegistryBucketKey, createIfMissing: boolean): Map<DocumentRegistryEntry> {
let bucket = buckets.get(key);
if (!bucket && createIfMissing) {
buckets.set(key, bucket = createMap<DocumentRegistryEntry>());
}
return bucket!; // TODO: GH#18217
}
function reportStats() {
const bucketInfoArray = arrayFrom(buckets.keys()).filter(name => name && name.charAt(0) === "_").map(name => {
const entries = buckets.get(name)!;
@ -178,7 +170,7 @@ namespace ts {
acquiring: boolean,
scriptKind?: ScriptKind): SourceFile {
const bucket = getBucketForCompilationSettings(key, /*createIfMissing*/ true);
const bucket = getOrUpdate<Map<DocumentRegistryEntry>>(buckets, key, createMap);
let entry = bucket.get(path);
const scriptTarget = scriptKind === ScriptKind.JSON ? ScriptTarget.JSON : compilationSettings.target || ScriptTarget.ES5;
if (!entry && externalCache) {
@ -238,9 +230,7 @@ namespace ts {
}
function releaseDocumentWithKey(path: Path, key: DocumentRegistryBucketKey): void {
const bucket = getBucketForCompilationSettings(key, /*createIfMissing*/ false);
Debug.assert(bucket !== undefined);
const bucket = Debug.assertDefined(buckets.get(key));
const entry = bucket.get(path)!;
entry.languageServiceRefCount--;