Skip to content

Commit 1f080a8

Browse files
author
Andy Hanson
committed
Remove more uses of 'get'
1 parent 7e05324 commit 1f080a8

File tree

5 files changed

+41
-38
lines changed

5 files changed

+41
-38
lines changed

src/compiler/sys.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,7 @@ namespace ts {
301301
if ((eventName === "change" || eventName === "rename")) {
302302
const callbacks = fileWatcherCallbacks.get(fileName);
303303
if (callbacks) {
304-
for (const fileCallback of fileWatcherCallbacks.get(fileName)) {
304+
for (const fileCallback of callbacks) {
305305
fileCallback(fileName);
306306
}
307307
}

src/compiler/transformers/module/module.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -581,7 +581,7 @@ namespace ts {
581581
function addExportMemberAssignments(statements: Statement[], name: Identifier): void {
582582
const specifiers = !exportEquals && exportSpecifiers && exportSpecifiers.get(name.text);
583583
if (specifiers) {
584-
for (const specifier of exportSpecifiers.get(name.text)) {
584+
for (const specifier of specifiers) {
585585
statements.push(
586586
startOnNewLine(
587587
createStatement(
@@ -672,7 +672,7 @@ namespace ts {
672672
if (specifiers) {
673673
const sourceFileId = getOriginalNodeId(currentSourceFile);
674674
const bindingNameExportSpecifiers = getOrUpdate(bindingNameExportSpecifiersForFileMap, sourceFileId, () => new StringMap());
675-
bindingNameExportSpecifiers.set(name.text, exportSpecifiers.get(name.text));
675+
bindingNameExportSpecifiers.set(name.text, specifiers);
676676
addExportMemberAssignments(resultStatements, name);
677677
}
678678
}
@@ -926,7 +926,7 @@ namespace ts {
926926
setEmitFlags(transformedUnaryExpression, EmitFlags.NoSubstitution);
927927
}
928928
let nestedExportAssignment: BinaryExpression;
929-
for (const specifier of bindingNameExportSpecifiersMap.get(operand.text)) {
929+
for (const specifier of bindingNameExportSpecifiers) {
930930
nestedExportAssignment = nestedExportAssignment ?
931931
createExportAssignment(specifier.name, nestedExportAssignment) :
932932
createExportAssignment(specifier.name, transformedUnaryExpression || node);

src/harness/fourslash.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -700,7 +700,8 @@ namespace FourSlash {
700700
const uniqueItems = new ts.StringMap<string>();
701701
for (const item of completions.entries) {
702702
if (!ts.setIfNotSet(uniqueItems, item.name, item.kind)) {
703-
assert.equal(item.kind, uniqueItems.get(item.name), `Items should have the same kind, got ${item.kind} and ${uniqueItems.get(item.name)}`);
703+
const uniqueItem = uniqueItems.get(item.name);
704+
assert.equal(item.kind, uniqueItem, `Items should have the same kind, got ${item.kind} and ${uniqueItem}`);
704705
}
705706
}
706707
}

src/harness/harness.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -933,10 +933,9 @@ namespace Harness {
933933
return undefined;
934934
}
935935

936-
if (!libFileNameSourceFileMap.get(fileName)) {
937-
libFileNameSourceFileMap.set(fileName, createSourceFileAndAssertInvariants(fileName, IO.readFile(libFolder + fileName), ts.ScriptTarget.Latest));
938-
}
939-
return libFileNameSourceFileMap.get(fileName);
936+
const sourceFile = libFileNameSourceFileMap.get(fileName);
937+
return sourceFile || ts.setAndReturn(libFileNameSourceFileMap, fileName,
938+
createSourceFileAndAssertInvariants(fileName, IO.readFile(libFolder + fileName), ts.ScriptTarget.Latest));
940939
}
941940

942941
export function getDefaultLibFileName(options: ts.CompilerOptions): string {

src/server/editorServices.ts

Lines changed: 32 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1238,40 +1238,43 @@ namespace ts.server {
12381238
// close existing project and later we'll open a set of configured projects for these files
12391239
this.closeExternalProject(proj.projectFileName, /*suppressRefresh*/ true);
12401240
}
1241-
else if (this.externalProjectToConfiguredProjectMap.get(proj.projectFileName)) {
1242-
// this project used to include config files
1243-
if (!tsConfigFiles) {
1244-
// config files were removed from the project - close existing external project which in turn will close configured projects
1245-
this.closeExternalProject(proj.projectFileName, /*suppressRefresh*/ true);
1246-
}
1247-
else {
1248-
// project previously had some config files - compare them with new set of files and close all configured projects that correspond to unused files
1249-
const oldConfigFiles = this.externalProjectToConfiguredProjectMap.get(proj.projectFileName);
1250-
let iNew = 0;
1251-
let iOld = 0;
1252-
while (iNew < tsConfigFiles.length && iOld < oldConfigFiles.length) {
1253-
const newConfig = tsConfigFiles[iNew];
1254-
const oldConfig = oldConfigFiles[iOld];
1255-
if (oldConfig < newConfig) {
1256-
this.closeConfiguredProject(oldConfig);
1257-
iOld++;
1258-
}
1259-
else if (oldConfig > newConfig) {
1260-
iNew++;
1241+
else {
1242+
const oldConfigFiles = this.externalProjectToConfiguredProjectMap.get(proj.projectFileName);
1243+
if (oldConfigFiles) {
1244+
// this project used to include config files
1245+
if (!tsConfigFiles) {
1246+
// config files were removed from the project - close existing external project which in turn will close configured projects
1247+
this.closeExternalProject(proj.projectFileName, /*suppressRefresh*/ true);
1248+
}
1249+
else {
1250+
// project previously had some config files - compare them with new set of files and close all configured projects that correspond to unused files
1251+
let iNew = 0;
1252+
let iOld = 0;
1253+
while (iNew < tsConfigFiles.length && iOld < oldConfigFiles.length) {
1254+
const newConfig = tsConfigFiles[iNew];
1255+
const oldConfig = oldConfigFiles[iOld];
1256+
if (oldConfig < newConfig) {
1257+
this.closeConfiguredProject(oldConfig);
1258+
iOld++;
1259+
}
1260+
else if (oldConfig > newConfig) {
1261+
iNew++;
1262+
}
1263+
else {
1264+
// record existing config files so avoid extra add-refs
1265+
(exisingConfigFiles || (exisingConfigFiles = [])).push(oldConfig);
1266+
iOld++;
1267+
iNew++;
1268+
}
12611269
}
1262-
else {
1263-
// record existing config files so avoid extra add-refs
1264-
(exisingConfigFiles || (exisingConfigFiles = [])).push(oldConfig);
1265-
iOld++;
1266-
iNew++;
1270+
for (let i = iOld; i < oldConfigFiles.length; i++) {
1271+
// projects for all remaining old config files should be closed
1272+
this.closeConfiguredProject(oldConfigFiles[i]);
12671273
}
12681274
}
1269-
for (let i = iOld; i < oldConfigFiles.length; i++) {
1270-
// projects for all remaining old config files should be closed
1271-
this.closeConfiguredProject(oldConfigFiles[i]);
1272-
}
12731275
}
12741276
}
1277+
12751278
if (tsConfigFiles) {
12761279
// store the list of tsconfig files that belong to the external project
12771280
this.externalProjectToConfiguredProjectMap.set(proj.projectFileName, tsConfigFiles);

0 commit comments

Comments
 (0)