mirror of
https://github.com/kovidgoyal/kitty
synced 2026-07-19 15:04:50 +02:00
Coalesce neighboring symbol maps for better lookup performance
This commit is contained in:
@@ -25,8 +25,29 @@ else:
|
||||
current_faces = None
|
||||
|
||||
|
||||
def coalesce_symbol_maps(maps):
|
||||
if not maps:
|
||||
return maps
|
||||
items = tuple((k, maps[k]) for k in sorted(maps))
|
||||
ans = [items[0]]
|
||||
|
||||
def merge(prev_item, item):
|
||||
s, e = item[0]
|
||||
pe = prev_item[0][1]
|
||||
ans[-1] = ((prev_item[0][0], max(pe, e)), prev_item[1])
|
||||
|
||||
for item in items[1:]:
|
||||
current_item = ans[-1]
|
||||
if current_item[1] != item[1] or item[0][0] > current_item[0][1] + 1:
|
||||
ans.append(item)
|
||||
else:
|
||||
merge(current_item, item)
|
||||
|
||||
return dict(ans)
|
||||
|
||||
|
||||
def create_symbol_map(opts):
|
||||
val = opts.symbol_map
|
||||
val = coalesce_symbol_maps(opts.symbol_map)
|
||||
family_map = {}
|
||||
count = 0
|
||||
for family in val.values():
|
||||
|
||||
Reference in New Issue
Block a user