Skip to content

perf: Skip JSON encoding/decoding for Lua editDisplay - #1625

Open
enzi221 wants to merge 1 commit into
kwaroran:mainfrom
enzi221:perf/avoid-extra-encdec
Open

enzi221 wants to merge 1 commit into
kwaroran:mainfrom
enzi221:perf/avoid-extra-encdec

Conversation

@enzi221

@enzi221 enzi221 commented Sep 19, 2026 •

Copy link
Copy Markdown
Contributor

PR Checklist

  • Required Checks
    • Have you added type definitions?
    • Have you tested your changes?
    • Have you checked that it won't break any existing features?

Summary

editDisplay does not take nor output a JSON. Skips JSON encoding/decoding.

Related Issues

None.

Changes

This enhances initial chat rendering time by over 30%. The exact percentage will vary by numbers of chat messages and Lua triggers.

In a Lua-heavy environment with 30 messages, it takes ~1.7s.

image

With this PR, it takes ~1.1s, which is a huge enhancement (34%).

image

Implementation details:

editDisplay takes a raw string, and must output a raw string (else it dies with e.replace is not a function even without this PR, so not a breaking change). Since string is also a primitive in Lua, JSON conversion is unnecessary.

Impact

None.

@enzi221
enzi221 force-pushed the perf/avoid-extra-encdec branch from 9ab6b8d to b0aba18 Compare October 8, 2026 13:08
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.

1 participant