# HG changeset patch # User Paul Boddie # Date 1693869841 -7200 # Node ID ff5db4d0d5d4468d533aacdd53fe0ec9a5657264 # Parent cdd61ff46fb7a9da7b580d69c27ee820a7ff04ef Fixed low-level attribute initialisation, avoiding object copying tests. diff -r cdd61ff46fb7 -r ff5db4d0d5d4 templates/native/common.c --- a/templates/native/common.c Tue Sep 05 00:27:39 2023 +0200 +++ b/templates/native/common.c Tue Sep 05 01:24:01 2023 +0200 @@ -30,9 +30,9 @@ { /* Create a new string and mutate the __data__, __size__ and __key__ attributes. */ __attr attr = __NEWINSTANCE(__builtins___str_str); - __store_via_attr_ref(__get_object_attr_ref(__VALUE(attr), __data__), (__attr) {.strvalue=s}); - __store_via_attr_ref(__get_object_attr_ref(__VALUE(attr), __size__), __INTVALUE(size)); - __store_via_attr_ref(__get_object_attr_ref(__VALUE(attr), __key__), __NULL); + __store_via_attr_ref__(__get_object_attr_ref(__VALUE(attr), __data__), (__attr) {.strvalue=s}); + __store_via_attr_ref__(__get_object_attr_ref(__VALUE(attr), __size__), __INTVALUE(size)); + __store_via_attr_ref__(__get_object_attr_ref(__VALUE(attr), __key__), __NULL); return attr; } @@ -40,7 +40,7 @@ { /* Create a new list and mutate the __data__ attribute. */ __attr attr = __NEWINSTANCE(__builtins___list_list); - __store_via_attr_ref(__get_object_attr_ref(__VALUE(attr), __data__), (__attr) {.seqvalue=f}); + __store_via_attr_ref__(__get_object_attr_ref(__VALUE(attr), __data__), (__attr) {.seqvalue=f}); return attr; } diff -r cdd61ff46fb7 -r ff5db4d0d5d4 templates/native/list.c --- a/templates/native/list.c Tue Sep 05 00:27:39 2023 +0200 +++ b/templates/native/list.c Tue Sep 05 01:24:01 2023 +0200 @@ -56,7 +56,7 @@ /* Replace the __data__ attribute if appropriate. */ if (newdata != data) - __store_via_attr_ref(__get_object_attr_ref(__VALUE(self), __data__), ((__attr) {.seqvalue=newdata})); + __store_via_attr_ref__(__get_object_attr_ref(__VALUE(self), __data__), ((__attr) {.seqvalue=newdata})); return __builtins___none_None; } @@ -84,7 +84,7 @@ /* Replace the __data__ attribute if appropriate. */ if (newdata != data) - __store_via_attr_ref(__get_object_attr_ref(__VALUE(self), __data__), ((__attr) {.seqvalue=newdata})); + __store_via_attr_ref__(__get_object_attr_ref(__VALUE(self), __data__), ((__attr) {.seqvalue=newdata})); return __builtins___none_None; } diff -r cdd61ff46fb7 -r ff5db4d0d5d4 templates/ops.h --- a/templates/ops.h Tue Sep 05 00:27:39 2023 +0200 +++ b/templates/ops.h Tue Sep 05 01:24:01 2023 +0200 @@ -46,6 +46,8 @@ #define __load_via_attr_ref(ATTR) (*(ATTR)) #define __store_via_attr_ref(ATTR, VALUE) __set_attr(ATTR, VALUE) +#define __store_via_attr_ref__(ATTR, VALUE) (*(ATTR) = VALUE) + /* Direct retrieval operations, returning attributes. */ __attr __load_via_class__(__ref obj, int pos); diff -r cdd61ff46fb7 -r ff5db4d0d5d4 templates/progops.c --- a/templates/progops.c Tue Sep 05 00:27:39 2023 +0200 +++ b/templates/progops.c Tue Sep 05 01:24:01 2023 +0200 @@ -32,7 +32,7 @@ { obj->table = table; obj->pos = __INSTANCEPOS; - __store_via_attr_ref(__get_object_attr_ref(obj, __class__), __ATTRVALUE(cls)); + __store_via_attr_ref__(__get_object_attr_ref(obj, __class__), __ATTRVALUE(cls)); } __attr __new(const __table * table, __ref cls, size_t size, int immutable) @@ -81,7 +81,7 @@ /* Store a reference to the data in the object's __data__ attribute. */ - __store_via_attr_ref(__get_object_attr_ref(__VALUE(self), __data__), (__attr) {.seqvalue=data}); + __store_via_attr_ref__(__get_object_attr_ref(__VALUE(self), __data__), (__attr) {.seqvalue=data}); __newdata_sequence(number, data, args); return self; } @@ -97,7 +97,7 @@ /* Store a reference to the data in the object's __data__ attribute. */ - __store_via_attr_ref(__get_object_attr_ref(__VALUE(self), __data__), (__attr) {.seqvalue=data}); + __store_via_attr_ref__(__get_object_attr_ref(__VALUE(self), __data__), (__attr) {.seqvalue=data}); __newdata_sequence(number, data, args); return self; } @@ -315,7 +315,7 @@ void __SETDEFAULT(__ref obj, int pos, __attr value) { - __store_via_attr_ref(__get_object_attr_ref__(obj, __FUNCTION_INSTANCE_SIZE + pos), value); + __store_via_attr_ref__(__get_object_attr_ref__(obj, __FUNCTION_INSTANCE_SIZE + pos), value); } __attr __GETDEFAULT(__ref obj, int pos)