# HG changeset patch # User Paul Boddie # Date 1486597001 -3600 # Node ID 2ef433e2f7c844fa490f0a74d12862de183c6481 # Parent c34d7d187b2c7aff1cd6f6974d88e0b4c995b481 Avoid repeated processing of the program type information. diff -r c34d7d187b2c -r 2ef433e2f7c8 optimiser.py --- a/optimiser.py Wed Feb 08 17:24:31 2017 +0100 +++ b/optimiser.py Thu Feb 09 00:36:41 2017 +0100 @@ -288,7 +288,7 @@ "Populate objects using attribute and usage information." - all_attrs = {} + self.all_attrs = {} # Partition attributes into separate sections so that class and instance # attributes are treated separately. @@ -298,10 +298,11 @@ (self.importer.all_instance_attrs, ""), (self.importer.all_module_attrs, "") ]: - for name, attrs in source.items(): - all_attrs[(objtype, name)] = attrs - self.locations = get_allocated_locations(all_attrs, get_attributes_and_sizes) + for name, attrnames in source.items(): + self.all_attrs[(objtype, name)] = attrnames + + self.locations = get_allocated_locations(self.all_attrs, get_attributes_and_sizes) def populate_parameters(self): @@ -323,20 +324,14 @@ # Record the structures. - for source, objtype in [ - (self.importer.all_class_attrs, ""), - (self.importer.all_instance_attrs, ""), - (self.importer.all_module_attrs, "") - ]: - - for name, attrnames in source.items(): - key = Reference(objtype, name) - l = self.structures[key] = [None] * len(attrnames) - for attrname in attrnames: - position = attr_locations[attrname] - if position >= len(l): - l.extend([None] * (position - len(l) + 1)) - l[position] = attrname + for (objtype, name), attrnames in self.all_attrs.items(): + key = Reference(objtype, name) + l = self.structures[key] = [None] * len(attrnames) + for attrname in attrnames: + position = attr_locations[attrname] + if position >= len(l): + l.extend([None] * (position - len(l) + 1)) + l[position] = attrname def initialise_access_instructions(self):