Skip to content

extract map copying logic to a separate function #1586

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

Merged
merged 2 commits into from
Jan 8, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions src/compiler/checker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3651,9 +3651,7 @@ module ts {
var maybeCache = maybeStack[depth];
// If result is definitely true, copy assumptions to global cache, else copy to next level up
var destinationCache = result === Ternary.True || depth === 0 ? relation : maybeStack[depth - 1];
for (var p in maybeCache) {
destinationCache[p] = maybeCache[p];
}
copyMap(/*source*/maybeCache, /*target*/destinationCache);
}
else {
// A false result goes straight into global cache (when something is false under assumptions it
Expand Down
6 changes: 6 additions & 0 deletions src/compiler/core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,12 @@ module ts {
return result;
}

export function copyMap<T>(source: Map<T>, target: Map<T>): void {
for (var p in source) {
target[p] = source[p];
}
}

/**
* Creates a map from the elements of an array.
*
Expand Down