# HG changeset patch # User Paul Boddie # Date 1490373892 -3600 # Node ID 05930170914dd0e06c5c2363d55a0e4e41633171 # Parent b496ef9d5ee1446ff1f20ee2c094e812c3ca8704 Avoid target unwrapping if it has been done already. diff -r b496ef9d5ee1 -r 05930170914d templates/ops.c --- a/templates/ops.c Thu Mar 23 16:40:57 2017 +0100 +++ b/templates/ops.c Fri Mar 24 17:44:52 2017 +0100 @@ -323,8 +323,11 @@ __attr (*__get_function(__attr context, __attr target))(__attr[]) { - target = __unwrap_callable(target); + return __get_function_unwrapped(context, __unwrap_callable(target)); +} +__attr (*__get_function_unwrapped(__attr context, __attr target))(__attr[]) +{ /* Require null or instance contexts for functions and methods respectively, or type instance contexts for type methods. */ @@ -336,8 +339,11 @@ __attr (*__check_and_get_function(__attr context, __attr target))(__attr[]) { - target = __unwrap_callable(target); + return __check_and_get_function_unwrapped(context, __unwrap_callable(target)); +} +__attr (*__check_and_get_function_unwrapped(__attr context, __attr target))(__attr[]) +{ /* Require null or instance contexts for functions and methods respectively, or type instance contexts for type methods. */ diff -r b496ef9d5ee1 -r 05930170914d templates/ops.h --- a/templates/ops.h Thu Mar 23 16:40:57 2017 +0100 +++ b/templates/ops.h Fri Mar 24 17:44:52 2017 +0100 @@ -114,7 +114,9 @@ __attr __unwrap_callable(__attr callable); __attr (*__get_function_unchecked(__attr target))(__attr[]); __attr (*__get_function(__attr context, __attr target))(__attr[]); +__attr (*__get_function_unwrapped(__attr context, __attr target))(__attr[]); __attr (*__check_and_get_function(__attr context, __attr target))(__attr[]); +__attr (*__check_and_get_function_unwrapped(__attr context, __attr target))(__attr[]); /* Parameter position operations. */ diff -r b496ef9d5ee1 -r 05930170914d templates/progops.c --- a/templates/progops.c Thu Mar 23 16:40:57 2017 +0100 +++ b/templates/progops.c Fri Mar 24 17:44:52 2017 +0100 @@ -253,7 +253,10 @@ /* Call with the prepared arguments. */ - return (always_callable ? __get_function(allargs[0], target) : __check_and_get_function(allargs[0], target))(allargs); + return (always_callable ? + __get_function_unwrapped(allargs[0], target) : + __check_and_get_function_unwrapped(allargs[0], target) + )(allargs); } /* Error routines. */