# HG changeset patch # User Paul Boddie # Date 1488573302 -3600 # Node ID 03ca7bd1abc0abac30df307da12cdd2aafb428bf # Parent b5e52aaecf41713719472d698547cbaf452bc43f Simplified the constant consolidation process by using the constant values mapping directly to generate the optimised mappings. diff -r b5e52aaecf41 -r 03ca7bd1abc0 optimiser.py --- a/optimiser.py Fri Mar 03 13:44:32 2017 +0100 +++ b/optimiser.py Fri Mar 03 21:35:02 2017 +0100 @@ -982,31 +982,28 @@ self.constants = {} - for path, constants in self.importer.all_constants.items(): - - # Record constants and obtain a number for them. - # Each constant is actually (value, value_type, encoding). - - for constant, n in constants.items(): - d = digest(constant) - self.constants[constant] = d - - # Make sure the digests are really distinct for different - # constants. - - if self.digests.has_key(d): - if self.digests[d] != constant: - raise OptimiseError, "Digest %s used for distinct constants %r and %r." % ( - d, self.digests[d], constant) - else: - self.digests[d] = constant - # Establish a mapping from local constant identifiers to consolidated # constant identifiers. self.constant_numbers = {} for name, constant in self.importer.all_constant_values.items(): + + # Each constant is actually (value, value_type, encoding). + + d = digest(constant) + self.constants[constant] = d + + # Make sure the digests are really distinct for different + # constants. + + if self.digests.has_key(d): + if self.digests[d] != constant: + raise OptimiseError, "Digest %s used for distinct constants %r and %r." % ( + d, self.digests[d], constant) + else: + self.digests[d] = constant + self.constant_numbers[name] = self.constants[constant] def combine_rows(a, b):