Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit aadcbcc

Browse filesBrowse files
author
Andy Hanson
committed
Use native maps when they're available
1 parent 3212e25 commit aadcbcc
Copy full SHA for aadcbcc

66 files changed

+1,678-1,326Lines changed: 1678 additions & 1326 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Dismiss banner
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎Jakefile.js‎

Copy file name to clipboardExpand all lines: Jakefile.js
+2Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ function measure(marker) {
5757
}
5858

5959
var compilerSources = [
60+
"dataStructures.ts",
6061
"core.ts",
6162
"performance.ts",
6263
"sys.ts",
@@ -91,6 +92,7 @@ var compilerSources = [
9192
});
9293

9394
var servicesSources = [
95+
"dataStructures.ts",
9496
"core.ts",
9597
"performance.ts",
9698
"sys.ts",
Collapse file

‎scripts/processDiagnosticMessages.ts‎

Copy file name to clipboardExpand all lines: scripts/processDiagnosticMessages.ts
+9-9Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ function main(): void {
2727

2828
var inputFilePath = sys.args[0].replace(/\\/g, "/");
2929
var inputStr = sys.readFile(inputFilePath);
30-
30+
3131
var diagnosticMessages: InputDiagnosticMessageTable = JSON.parse(inputStr);
3232

3333
var names = Utilities.getObjectKeys(diagnosticMessages);
@@ -44,7 +44,7 @@ function main(): void {
4444
function checkForUniqueCodes(messages: string[], diagnosticTable: InputDiagnosticMessageTable) {
4545
const originalMessageForCode: string[] = [];
4646
let numConflicts = 0;
47-
47+
4848
for (const currentMessage of messages) {
4949
const code = diagnosticTable[currentMessage].code;
5050

@@ -68,19 +68,19 @@ function checkForUniqueCodes(messages: string[], diagnosticTable: InputDiagnosti
6868
}
6969
}
7070

71-
function buildUniqueNameMap(names: string[]): ts.Map<string> {
72-
var nameMap = ts.createMap<string>();
71+
function buildUniqueNameMap(names: string[]): ts.Map<string, string> {
72+
var nameMap = new ts.StringMap<string>();
7373

7474
var uniqueNames = NameGenerator.ensureUniqueness(names, /* isCaseSensitive */ false, /* isFixed */ undefined);
7575

7676
for (var i = 0; i < names.length; i++) {
77-
nameMap[names[i]] = uniqueNames[i];
77+
nameMap.set(names[i], uniqueNames[i]);
7878
}
7979

8080
return nameMap;
8181
}
8282

83-
function buildInfoFileOutput(messageTable: InputDiagnosticMessageTable, nameMap: ts.Map<string>): string {
83+
function buildInfoFileOutput(messageTable: InputDiagnosticMessageTable, nameMap: ts.Map<string, string>): string {
8484
var result =
8585
'// <auto-generated />\r\n' +
8686
'/// <reference path="types.ts" />\r\n' +
@@ -91,7 +91,7 @@ function buildInfoFileOutput(messageTable: InputDiagnosticMessageTable, nameMap:
9191
for (var i = 0; i < names.length; i++) {
9292
var name = names[i];
9393
var diagnosticDetails = messageTable[name];
94-
var propName = convertPropertyName(nameMap[name]);
94+
var propName = convertPropertyName(nameMap.get(name));
9595

9696
result +=
9797
' ' + propName +
@@ -107,14 +107,14 @@ function buildInfoFileOutput(messageTable: InputDiagnosticMessageTable, nameMap:
107107
return result;
108108
}
109109

110-
function buildDiagnosticMessageOutput(messageTable: InputDiagnosticMessageTable, nameMap: ts.Map<string>): string {
110+
function buildDiagnosticMessageOutput(messageTable: InputDiagnosticMessageTable, nameMap: ts.Map<string, string>): string {
111111
var result =
112112
'{';
113113
var names = Utilities.getObjectKeys(messageTable);
114114
for (var i = 0; i < names.length; i++) {
115115
var name = names[i];
116116
var diagnosticDetails = messageTable[name];
117-
var propName = convertPropertyName(nameMap[name]);
117+
var propName = convertPropertyName(nameMap.get(name));
118118

119119
result += '\r\n "' + createKey(propName, diagnosticDetails.code) + '"' + ' : "' + name.replace(/[\"]/g, '\\"') + '"';
120120
if (i !== names.length - 1) {
Collapse file

‎src/compiler/binder.ts‎

Copy file name to clipboardExpand all lines: src/compiler/binder.ts
+22-22Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ namespace ts {
126126

127127
let symbolCount = 0;
128128
let Symbol: { new (flags: SymbolFlags, name: string): Symbol };
129-
let classifiableNames: Map<string>;
129+
let classifiableNames: Set<string>;
130130

131131
const unreachableFlow: FlowNode = { flags: FlowFlags.Unreachable };
132132
const reportedUnreachableFlow: FlowNode = { flags: FlowFlags.Unreachable };
@@ -140,7 +140,7 @@ namespace ts {
140140
options = opts;
141141
languageVersion = getEmitScriptTarget(options);
142142
inStrictMode = !!file.externalModuleIndicator;
143-
classifiableNames = createMap<string>();
143+
classifiableNames = new StringSet();
144144
symbolCount = 0;
145145
skipTransformFlagAggregation = isDeclarationFile(file);
146146

@@ -190,11 +190,11 @@ namespace ts {
190190
symbol.declarations.push(node);
191191

192192
if (symbolFlags & SymbolFlags.HasExports && !symbol.exports) {
193-
symbol.exports = createMap<Symbol>();
193+
symbol.exports = new StringMap<Symbol>();
194194
}
195195

196196
if (symbolFlags & SymbolFlags.HasMembers && !symbol.members) {
197-
symbol.members = createMap<Symbol>();
197+
symbol.members = new StringMap<Symbol>();
198198
}
199199

200200
if (symbolFlags & SymbolFlags.Value) {
@@ -332,17 +332,17 @@ namespace ts {
332332
// Otherwise, we'll be merging into a compatible existing symbol (for example when
333333
// you have multiple 'vars' with the same name in the same container). In this case
334334
// just add this node into the declarations list of the symbol.
335-
symbol = symbolTable[name] || (symbolTable[name] = createSymbol(SymbolFlags.None, name));
335+
symbol = getOrUpdate(symbolTable, name, name => createSymbol(SymbolFlags.None, name));
336336

337337
if (name && (includes & SymbolFlags.Classifiable)) {
338-
classifiableNames[name] = name;
338+
classifiableNames.add(name);
339339
}
340340

341341
if (symbol.flags & excludes) {
342342
if (symbol.isReplaceableByMethod) {
343343
// Javascript constructor-declared symbols can be discarded in favor of
344344
// prototype symbols like methods.
345-
symbol = symbolTable[name] = createSymbol(SymbolFlags.None, name);
345+
symbol = setAndReturn(symbolTable, name, createSymbol(SymbolFlags.None, name));
346346
}
347347
else {
348348
if (node.name) {
@@ -450,7 +450,7 @@ namespace ts {
450450
if (containerFlags & ContainerFlags.IsContainer) {
451451
container = blockScopeContainer = node;
452452
if (containerFlags & ContainerFlags.HasLocals) {
453-
container.locals = createMap<Symbol>();
453+
container.locals = new StringMap<Symbol>();
454454
}
455455
addToContainerChain(container);
456456
}
@@ -1447,8 +1447,7 @@ namespace ts {
14471447

14481448
const typeLiteralSymbol = createSymbol(SymbolFlags.TypeLiteral, "__type");
14491449
addDeclarationToSymbol(typeLiteralSymbol, node, SymbolFlags.TypeLiteral);
1450-
typeLiteralSymbol.members = createMap<Symbol>();
1451-
typeLiteralSymbol.members[symbol.name] = symbol;
1450+
typeLiteralSymbol.members = createMapWithEntry(symbol.name, symbol);
14521451
}
14531452

14541453
function bindObjectLiteralExpression(node: ObjectLiteralExpression) {
@@ -1458,7 +1457,7 @@ namespace ts {
14581457
}
14591458

14601459
if (inStrictMode) {
1461-
const seen = createMap<ElementKind>();
1460+
const seen = new StringMap<ElementKind>();
14621461

14631462
for (const prop of node.properties) {
14641463
if (prop.name.kind !== SyntaxKind.Identifier) {
@@ -1479,9 +1478,9 @@ namespace ts {
14791478
? ElementKind.Property
14801479
: ElementKind.Accessor;
14811480

1482-
const existingKind = seen[identifier.text];
1481+
const existingKind = seen.get(identifier.text);
14831482
if (!existingKind) {
1484-
seen[identifier.text] = currentKind;
1483+
seen.set(identifier.text, currentKind);
14851484
continue;
14861485
}
14871486

@@ -1514,7 +1513,7 @@ namespace ts {
15141513
// fall through.
15151514
default:
15161515
if (!blockScopeContainer.locals) {
1517-
blockScopeContainer.locals = createMap<Symbol>();
1516+
blockScopeContainer.locals = new StringMap<Symbol>();
15181517
addToContainerChain(blockScopeContainer);
15191518
}
15201519
declareSymbol(blockScopeContainer.locals, undefined, node, symbolFlags, symbolExcludes);
@@ -1976,7 +1975,7 @@ namespace ts {
19761975
}
19771976
}
19781977

1979-
file.symbol.globalExports = file.symbol.globalExports || createMap<Symbol>();
1978+
file.symbol.globalExports = file.symbol.globalExports || new StringMap<Symbol>();
19801979
declareSymbol(file.symbol.globalExports, file.symbol, node, SymbolFlags.Alias, SymbolFlags.AliasExcludes);
19811980
}
19821981

@@ -2021,7 +2020,7 @@ namespace ts {
20212020
Debug.assert(isInJavaScriptFile(node));
20222021
// Declare a 'member' if the container is an ES5 class or ES6 constructor
20232022
if (container.kind === SyntaxKind.FunctionDeclaration || container.kind === SyntaxKind.FunctionExpression) {
2024-
container.symbol.members = container.symbol.members || createMap<Symbol>();
2023+
container.symbol.members = container.symbol.members || new StringMap<Symbol>();
20252024
// It's acceptable for multiple 'this' assignments of the same identifier to occur
20262025
declareSymbol(container.symbol.members, container.symbol, node, SymbolFlags.Property, SymbolFlags.PropertyExcludes & ~SymbolFlags.Property);
20272026
}
@@ -2053,14 +2052,14 @@ namespace ts {
20532052
constructorFunction.parent = classPrototype;
20542053
classPrototype.parent = leftSideOfAssignment;
20552054

2056-
const funcSymbol = container.locals[constructorFunction.text];
2055+
const funcSymbol = container.locals.get(constructorFunction.text);
20572056
if (!funcSymbol || !(funcSymbol.flags & SymbolFlags.Function || isDeclarationOfFunctionExpression(funcSymbol))) {
20582057
return;
20592058
}
20602059

20612060
// Set up the members collection if it doesn't exist already
20622061
if (!funcSymbol.members) {
2063-
funcSymbol.members = createMap<Symbol>();
2062+
funcSymbol.members = new StringMap<Symbol>();
20642063
}
20652064

20662065
// Declare the method/property
@@ -2093,7 +2092,7 @@ namespace ts {
20932092
bindAnonymousDeclaration(node, SymbolFlags.Class, bindingName);
20942093
// Add name of class expression into the map for semantic classifier
20952094
if (node.name) {
2096-
classifiableNames[node.name.text] = node.name.text;
2095+
classifiableNames.add(node.name.text);
20972096
}
20982097
}
20992098

@@ -2109,14 +2108,15 @@ namespace ts {
21092108
// module might have an exported variable called 'prototype'. We can't allow that as
21102109
// that would clash with the built-in 'prototype' for the class.
21112110
const prototypeSymbol = createSymbol(SymbolFlags.Property | SymbolFlags.Prototype, "prototype");
2112-
if (symbol.exports[prototypeSymbol.name]) {
2111+
const symbolExport = symbol.exports.get(prototypeSymbol.name);
2112+
if (symbolExport) {
21132113
if (node.name) {
21142114
node.name.parent = node;
21152115
}
2116-
file.bindDiagnostics.push(createDiagnosticForNode(symbol.exports[prototypeSymbol.name].declarations[0],
2116+
file.bindDiagnostics.push(createDiagnosticForNode(symbolExport.declarations[0],
21172117
Diagnostics.Duplicate_identifier_0, prototypeSymbol.name));
21182118
}
2119-
symbol.exports[prototypeSymbol.name] = prototypeSymbol;
2119+
symbol.exports.set(prototypeSymbol.name, prototypeSymbol);
21202120
prototypeSymbol.parent = symbol;
21212121
}
21222122

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.