Spped up fonts_are_identical

This commit is contained in:
Kovid Goyal 2019-07-28 21:01:55 +05:30
parent e77df26174
commit bdebe91156
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C

View File

@ -775,10 +775,14 @@ def merge_cmaps(cmaps):
def fonts_are_identical(fonts):
sentinel = object()
for key in ('ToUnicode', 'Data'):
all_values = {f[key] for f in fonts}
if len(all_values) > 1:
return False
prev_val = sentinel
for f in fonts:
val = f[key]
if prev_val is not sentinel and prev_val != val:
return False
prev_val = val
return True