Check for overflows in a loop
This commit is contained in:
parent
f9b927cdbb
commit
f53a75fb1d
@ -377,12 +377,6 @@ class ChainContextualBuilder(LookupBuilder):
|
|||||||
candidates = [None, None, None, []]
|
candidates = [None, None, None, []]
|
||||||
for rule in ruleset.rules:
|
for rule in ruleset.rules:
|
||||||
candidates[3].append(self.buildFormat3Subtable(rule, chaining))
|
candidates[3].append(self.buildFormat3Subtable(rule, chaining))
|
||||||
# Check we can build it
|
|
||||||
try:
|
|
||||||
self.getCompiledSize_(candidates[3])
|
|
||||||
except Exception as e:
|
|
||||||
log.warning("Contextual format 3 at %s overflowed" % str(self.location))
|
|
||||||
candidates[3] = None
|
|
||||||
|
|
||||||
# Can we express the whole ruleset as a format 2 subtable?
|
# Can we express the whole ruleset as a format 2 subtable?
|
||||||
classdefs = ruleset.format2ClassDefs()
|
classdefs = ruleset.format2ClassDefs()
|
||||||
@ -390,21 +384,19 @@ class ChainContextualBuilder(LookupBuilder):
|
|||||||
candidates[2] = [
|
candidates[2] = [
|
||||||
self.buildFormat2Subtable(ruleset, classdefs, chaining)
|
self.buildFormat2Subtable(ruleset, classdefs, chaining)
|
||||||
]
|
]
|
||||||
# Check we can build it
|
|
||||||
try:
|
|
||||||
self.getCompiledSize_(candidates[2])
|
|
||||||
except Exception as e:
|
|
||||||
log.warning("Contextual format 2 at %s overflowed (%s)" % (str(self.location), e))
|
|
||||||
candidates[2] = None
|
|
||||||
|
|
||||||
if not ruleset.hasAnyGlyphClasses:
|
if not ruleset.hasAnyGlyphClasses:
|
||||||
candidates[1] = [self.buildFormat1Subtable(ruleset, chaining)]
|
candidates[1] = [self.buildFormat1Subtable(ruleset, chaining)]
|
||||||
# Check we can build it
|
|
||||||
|
for i in [1, 2, 3]:
|
||||||
try:
|
try:
|
||||||
self.getCompiledSize_(candidates[1])
|
self.getCompiledSize_(candidates[i])
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
log.warning("Contextual format 1 at %s overflowed" % str(self.location))
|
log.warning(
|
||||||
candidates[1] = None
|
"Contextual format %i at %s overflowed (%s)"
|
||||||
|
% (i, str(self.location), e)
|
||||||
|
)
|
||||||
|
candidates[i] = None
|
||||||
|
|
||||||
candidates = [x for x in candidates if x is not None]
|
candidates = [x for x in candidates if x is not None]
|
||||||
if not candidates:
|
if not candidates:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user