From 51e1f2cbed85a302390f19fa69d1974ffc25630a Mon Sep 17 00:00:00 2001 From: Nikita Nemkin Date: Sat, 4 May 2013 13:24:58 +0600 Subject: [PATCH] Do not generate tables for completely empty slot suites. --- Cython/Compiler/TypeSlots.py | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/Cython/Compiler/TypeSlots.py b/Cython/Compiler/TypeSlots.py index ec89fc4..0413e4a 100644 --- a/Cython/Compiler/TypeSlots.py +++ b/Cython/Compiler/TypeSlots.py @@ -418,21 +418,30 @@ class SuiteSlot(SlotDescriptor): self.slot_type = slot_type substructures.append(self) + def is_empty(self, scope): + for slot in self.sub_slots: + if slot.slot_code(scope) != "0": + return False + return True + def substructure_cname(self, scope): return "%s%s_%s" % (Naming.pyrex_prefix, self.slot_name, scope.class_name) def slot_code(self, scope): - return "&%s" % self.substructure_cname(scope) + if not self.is_empty(scope): + return "&%s" % self.substructure_cname(scope) + return "0" def generate_substructure(self, scope, code): - code.putln("") - code.putln( - "static %s %s = {" % ( - self.slot_type, - self.substructure_cname(scope))) - for slot in self.sub_slots: - slot.generate(scope, code) - code.putln("};") + if not self.is_empty(scope): + code.putln("") + code.putln( + "static %s %s = {" % ( + self.slot_type, + self.substructure_cname(scope))) + for slot in self.sub_slots: + slot.generate(scope, code) + code.putln("};") substructures = [] # List of all SuiteSlot instances -- 2.7.4