From 363587163b4e83d6e6abdf92ce3f96653fca1e65 Mon Sep 17 00:00:00 2001 From: Vladimir Matveev Date: Fri, 2 Jan 2015 12:14:02 -0800 Subject: [PATCH 1/2] extract map copying logic to a separate function --- src/compiler/checker.ts | 4 +--- src/compiler/core.ts | 6 ++++++ 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index f8c4caa9630..351f5188748 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -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(maybeCache, destinationCache); } else { // A false result goes straight into global cache (when something is false under assumptions it diff --git a/src/compiler/core.ts b/src/compiler/core.ts index 4ba93729c36..2e5a471bb27 100644 --- a/src/compiler/core.ts +++ b/src/compiler/core.ts @@ -208,6 +208,12 @@ module ts { return result; } + export function copyMap(source: Map, target: Map): void { + for (var p in source) { + target[p] = source[p]; + } + } + /** * Creates a map from the elements of an array. * From 06258b8c106385924077c4a17d908114612dea0b Mon Sep 17 00:00:00 2001 From: Vladimir Matveev Date: Mon, 5 Jan 2015 11:48:46 -0800 Subject: [PATCH 2/2] added parameter names to 'copymap' call site --- src/compiler/checker.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 351f5188748..2911322052d 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -3651,7 +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]; - copyMap(maybeCache, destinationCache); + copyMap(/*source*/maybeCache, /*target*/destinationCache); } else { // A false result goes straight into global cache (when something is false under assumptions it