Skip to content

Commit 5562810

Browse files
committed
Merge pull request #1586 from Microsoft/copymap
extract map copying logic to a separate function
2 parents 7b11621 + 06258b8 commit 5562810

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

src/compiler/checker.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3652,9 +3652,7 @@ module ts {
36523652
var maybeCache = maybeStack[depth];
36533653
// If result is definitely true, copy assumptions to global cache, else copy to next level up
36543654
var destinationCache = result === Ternary.True || depth === 0 ? relation : maybeStack[depth - 1];
3655-
for (var p in maybeCache) {
3656-
destinationCache[p] = maybeCache[p];
3657-
}
3655+
copyMap(/*source*/maybeCache, /*target*/destinationCache);
36583656
}
36593657
else {
36603658
// A false result goes straight into global cache (when something is false under assumptions it

src/compiler/core.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,12 @@ module ts {
208208
return result;
209209
}
210210

211+
export function copyMap<T>(source: Map<T>, target: Map<T>): void {
212+
for (var p in source) {
213+
target[p] = source[p];
214+
}
215+
}
216+
211217
/**
212218
* Creates a map from the elements of an array.
213219
*

0 commit comments

Comments
 (0)