-
Notifications
You must be signed in to change notification settings - Fork 12.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use native maps when they're available #12715
Merged
Changes from 5 commits
Commits
Show all changes
30 commits
Select commit
Hold shift + click to select a range
6b1cc89
Use native maps when they're available
b15ffda
Simplify forEachKeyInMap and someKeyInMap
863e4d6
Clean up helpers
8121de7
Fix target error for gulp
8dbb8e7
Add comment
55fc62b
Merge branch 'master' into map5
5c304d0
Remove `createObject`; use `Object.create` directly.
b53b5cf
Remove the "set" function and use `map.set` with multiple lines of co…
8386d49
Use sparse arrays for number-keyed maps
5555258
Add iterators to Map interface, and shim iterators
3d7b5e6
Make `createMapLike` private and rename to `createDictionaryObject`
9e33585
Merge branch 'master' into map5
f510897
Remove "sparseArray" constructor function and just use array literals
39c19a7
Inline `keysOfMap` and `valuesOfMap`.
932eaa3
Rename and consolidate map iteration helpers
145f0b2
Add `createMultiMap` to replace `multiMapAdd` and `multiMapRemove`
346a865
Merge branch 'master' into map5
2e6f369
Replace SparseArray<T> with T[]
a677712
Merge branch 'master' into map5
8c5afd7
Merge branch 'master' into map5
9221336
Fix name: `mapEntries` is more accurate
c28d98a
Fix test
a0641b2
Merge branch 'master' into map5
f0e1fd9
Merge branch 'master' into map5
37e18d9
Add `createMapFromTemplate` helper
30462e1
Merge branch 'master' into map5
b98e82e
Fix one more use of `createMapFromTemplate`
113338c
Merge branch 'master' into map5
6b6c34b
Fix typo
30ccc7a
Merge branch 'master' into map5
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -349,17 +349,17 @@ namespace ts { | |
// Otherwise, we'll be merging into a compatible existing symbol (for example when | ||
// you have multiple 'vars' with the same name in the same container). In this case | ||
// just add this node into the declarations list of the symbol. | ||
symbol = symbolTable[name] || (symbolTable[name] = createSymbol(SymbolFlags.None, name)); | ||
symbol = symbolTable.get(name) || set(symbolTable, name, createSymbol(SymbolFlags.None, name)); | ||
|
||
if (name && (includes & SymbolFlags.Classifiable)) { | ||
classifiableNames[name] = name; | ||
classifiableNames.set(name, name); | ||
} | ||
|
||
if (symbol.flags & excludes) { | ||
if (symbol.isReplaceableByMethod) { | ||
// Javascript constructor-declared symbols can be discarded in favor of | ||
// prototype symbols like methods. | ||
symbol = symbolTable[name] = createSymbol(SymbolFlags.None, name); | ||
symbol = set(symbolTable, name, createSymbol(SymbolFlags.None, name)); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This could be |
||
} | ||
else { | ||
if (node.name) { | ||
|
@@ -1570,7 +1570,7 @@ namespace ts { | |
const typeLiteralSymbol = createSymbol(SymbolFlags.TypeLiteral, "__type"); | ||
addDeclarationToSymbol(typeLiteralSymbol, node, SymbolFlags.TypeLiteral); | ||
typeLiteralSymbol.members = createMap<Symbol>(); | ||
typeLiteralSymbol.members[symbol.name] = symbol; | ||
typeLiteralSymbol.members.set(symbol.name, symbol); | ||
} | ||
|
||
function bindObjectLiteralExpression(node: ObjectLiteralExpression) { | ||
|
@@ -1601,9 +1601,9 @@ namespace ts { | |
? ElementKind.Property | ||
: ElementKind.Accessor; | ||
|
||
const existingKind = seen[identifier.text]; | ||
const existingKind = seen.get(identifier.text); | ||
if (!existingKind) { | ||
seen[identifier.text] = currentKind; | ||
seen.set(identifier.text, currentKind); | ||
continue; | ||
} | ||
|
||
|
@@ -2208,7 +2208,7 @@ namespace ts { | |
constructorFunction.parent = classPrototype; | ||
classPrototype.parent = leftSideOfAssignment; | ||
|
||
const funcSymbol = container.locals[constructorFunction.text]; | ||
const funcSymbol = container.locals.get(constructorFunction.text); | ||
if (!funcSymbol || !(funcSymbol.flags & SymbolFlags.Function || isDeclarationOfFunctionExpression(funcSymbol))) { | ||
return; | ||
} | ||
|
@@ -2239,7 +2239,7 @@ namespace ts { | |
bindAnonymousDeclaration(node, SymbolFlags.Class, bindingName); | ||
// Add name of class expression into the map for semantic classifier | ||
if (node.name) { | ||
classifiableNames[node.name.text] = node.name.text; | ||
classifiableNames.set(node.name.text, node.name.text); | ||
} | ||
} | ||
|
||
|
@@ -2255,14 +2255,14 @@ namespace ts { | |
// module might have an exported variable called 'prototype'. We can't allow that as | ||
// that would clash with the built-in 'prototype' for the class. | ||
const prototypeSymbol = createSymbol(SymbolFlags.Property | SymbolFlags.Prototype, "prototype"); | ||
if (symbol.exports[prototypeSymbol.name]) { | ||
const symbolExport = symbol.exports.get(prototypeSymbol.name); | ||
if (symbolExport) { | ||
if (node.name) { | ||
node.name.parent = node; | ||
} | ||
file.bindDiagnostics.push(createDiagnosticForNode(symbol.exports[prototypeSymbol.name].declarations[0], | ||
Diagnostics.Duplicate_identifier_0, prototypeSymbol.name)); | ||
file.bindDiagnostics.push(createDiagnosticForNode(symbolExport.declarations[0], Diagnostics.Duplicate_identifier_0, prototypeSymbol.name)); | ||
} | ||
symbol.exports[prototypeSymbol.name] = prototypeSymbol; | ||
symbol.exports.set(prototypeSymbol.name, prototypeSymbol); | ||
prototypeSymbol.parent = symbol; | ||
} | ||
|
||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This doesn't need to be on one line. I'd rather see this as multiple lines and ditch the
set
function.