Skip to content

Optimize MDI metadata file (88% smaller) and add weekly optimizer workflow#28

Draft
Copilot wants to merge 1 commit into
mainfrom
copilot/optimize-mdi-metadata-file
Draft

Optimize MDI metadata file (88% smaller) and add weekly optimizer workflow#28
Copilot wants to merge 1 commit into
mainfrom
copilot/optimize-mdi-metadata-file

Conversation

Copilot AI commented Apr 28, 2026

Copy link
Copy Markdown

Ports the MDI metadata optimization from argon_industria_oled. The original materialdesignicons-webfont_meta.json (~3.16 MB) carried per-icon UUIDs, tags, authors, versions and empty alias arrays — none of which are used at render time. Flattening to a name/alias → codepoint map shrinks it to ~354 KB (88.8%) and replaces the O(n) scans in icons.py with a single dict lookup.

Changes

  • scripts/optimize_materialdesignicons_meta.py — flattens the metadata, sorted, written compact (no whitespace). Idempotent on already-optimized input so the workflow is safe to re-run.
  • materialdesignicons-webfont.meta.json — new optimized asset; old materialdesignicons-webfont_meta.json removed. New file name per the problem statement.
  • custom_components/opendisplay/imagegen/icons.pydraw_icon and draw_icon_sequence now do mdi_data.get(icon_name) against the flat dict. The old list-of-objects format is no longer supported (no backward-compat path requested).
  • .github/workflows/optimize-mdi-metadata.yaml — weekly (Mon 00:00 UTC) + workflow_dispatch. Runs the optimizer, and if the file changed, closes any prior automated PR for the same base branch and opens a new one with before/after size stats. Branch name is sanitized for refs containing /.

Lookup before/after

# before: linear scan over ~7.3k entries, then a second scan over aliases
for icon in mdi_data:
    if icon['name'] == icon_name:
        chr_hex = icon['codepoint']; break
if not chr_hex:
    for icon in mdi_data:
        if 'aliases' in icon and icon_name in icon['aliases']:
            chr_hex = icon['codepoint']; break

# after: single hash lookup, aliases pre-merged at build time
chr_hex = mdi_data.get(icon_name)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants