From 495caf0f6728e881e67b7fbe077a2c782b8e3f4d Mon Sep 17 00:00:00 2001 From: Jason Freeman Date: Fri, 13 Mar 2015 17:03:13 -0700 Subject: [PATCH] Optimize the clearing of inferredTypes --- src/compiler/checker.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 44178aed74b..0d29e928e31 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -6344,7 +6344,11 @@ module ts { // Clear out all the inference results from the last time inferTypeArguments was called on this context for (let i = 0; i < typeParameters.length; i++) { - context.inferredTypes[i] = undefined; + // As an optimization, we don't have to clear (and later recompute) inferred types + // for type parameters that have already been fixed on the previous call to inferTypeArguments + if (!context.inferences[i].isFixed) { + context.inferredTypes[i] = undefined; + } } // We perform two passes over the arguments. In the first pass we infer from all arguments, but use