# HG changeset patch # User Paul Boddie # Date 1530630165 -7200 # Node ID 00fd6721188270e57622363de0df3c5fdf091bfb # Parent 4bf5180fbfeea4f4d505238f0f688ea306db1f95 Take advantage of context testing when acquiring functions for invocation. Since a context whose nature has been determined will have been tested, either as a consequence of deduction or at run-time, use of __get_function (which tests the context again) is unnecessary. diff -r 4bf5180fbfee -r 00fd67211882 translator.py --- a/translator.py Mon Jul 02 19:19:54 2018 +0200 +++ b/translator.py Tue Jul 03 17:02:45 2018 +0200 @@ -1403,12 +1403,14 @@ elif function: if context_required: + + # With context_verified or context_identity... + if have_access_context: - if context_verified: - emit("__get_function_member(%s)" % target_expr) - else: - emit("__get_function(%s, %s)" % ( - context_identity, target_expr)) + emit("__get_function_member(%s)" % target_expr) + + # Otherwise, test the context for the function/method. + else: emit("__get_function(__CONTEXT_AS_VALUE(%s), %s)" % ( target_var, target_expr)) @@ -1420,7 +1422,7 @@ elif known_parameters: context_arg = context_required and args[0] or "__NULL" if self.always_callable(refs): - if context_verified: + if context_verified or context_identity: emit("__get_function_member(%s)" % target_expr) else: emit("__get_function(%s, %s)" % (context_arg, target_expr))