@@ -1265,23 +1265,30 @@ mp_obj_t mp_obj_new_type(qstr name, mp_obj_t bases_tuple, mp_obj_t locals_dict)
1265
1265
#if MICROPY_PY_METACLASSES_LITE || ENABLE_SPECIAL_ACCESSORS
1266
1266
// Check if the class has any special accessor methods,
1267
1267
// and accumulate bound __set_name__ methods that need to be called
1268
- if (MICROPY_PY_METACLASSES_LITE || !(o -> flags & MP_TYPE_FLAG_HAS_SPECIAL_ACCESSORS )) {
1269
- for (size_t i = 0 ; i < locals_ptr -> map .alloc ; i ++ ) {
1270
- if (mp_map_slot_is_filled (& locals_ptr -> map , i )) {
1271
- const mp_map_elem_t * elem = & locals_ptr -> map .table [i ];
1272
- if (check_for_special_accessors (elem -> key , elem -> value )) {
1273
- o -> flags |= MP_TYPE_FLAG_HAS_SPECIAL_ACCESSORS ;
1274
- #if !(MICROPY_PY_METACLASSES_LITE )
1275
- break ;
1276
- #endif
1277
- }
1278
- #if MICROPY_PY_METACLASSES_LITE
1279
- setname_tail = setname_maybe_bind_append (setname_tail , elem -> key , elem -> value );
1280
- #endif
1268
+ for (size_t i = 0 ; i < locals_ptr -> map .alloc ; i ++ ) {
1269
+ #if !MICROPY_PY_METACLASSES_LITE
1270
+ // metaclasses-lite needs to scan the entire locals map, can't early-terminate
1271
+ if (o -> flags & MP_TYPE_FLAG_HAS_SPECIAL_ACCESSORS ) {
1272
+ break ;
1273
+ }
1274
+ #endif
1275
+
1276
+ if (mp_map_slot_is_filled (& locals_ptr -> map , i )) {
1277
+ const mp_map_elem_t * elem = & locals_ptr -> map .table [i ];
1278
+
1279
+ #if ENABLE_SPECIAL_ACCESSORS
1280
+ if ((o -> flags & MP_TYPE_FLAG_HAS_SPECIAL_ACCESSORS ) // elidable when the early-termination check is enabled
1281
+ && check_for_special_accessors (elem -> key , elem -> value )) {
1282
+ o -> flags |= MP_TYPE_FLAG_HAS_SPECIAL_ACCESSORS ;
1281
1283
}
1284
+ #endif
1285
+
1286
+ #if MICROPY_PY_METACLASSES_LITE
1287
+ setname_tail = setname_maybe_bind_append (setname_tail , elem -> key , elem -> value );
1288
+ #endif
1282
1289
}
1283
1290
}
1284
- #endif
1291
+ #endif // MICROPY_PY_METACLASSES_LITE || ENABLE_SPECIAL_ACCESSORS
1285
1292
1286
1293
const mp_obj_type_t * native_base ;
1287
1294
size_t num_native_bases = instance_count_native_bases (o , & native_base );
0 commit comments