# HG changeset patch # User Paul Boddie # Date 1549301428 -3600 # Node ID a13fc2cc28f0205df39a42819e553097da86acb9 # Parent 2cbff01cc5866016ffc2bc9b889e0a13d987bde7 Optimised __BOOL to test for integers and to return int values directly. For other value types, __VALUE need not be called once integers have been excluded, and so the attrvalue member can be accessed directly. diff -r 2cbff01cc586 -r a13fc2cc28f0 templates/progops.c --- a/templates/progops.c Sat Feb 02 17:54:22 2019 +0100 +++ b/templates/progops.c Mon Feb 04 18:30:28 2019 +0100 @@ -304,9 +304,17 @@ int __BOOL(__attr attr) { - /* Invoke the bool function with the object and test against True. */ + __ref value; + + /* Integers can be used directly as truth values. */ - __ref value = __VALUE(attr); + if (__INTEGER(attr)) + return __TOINT(attr); + + /* Test against True and False explicitly. If necessary, invoke the bool + function with the object and test against True. */ + + value = attr.value; return value == &__predefined___builtins___boolean_True ? 1 : value == &__predefined___builtins___boolean_False ? 0 :