JSON encoding currently formats each ASCII control character without a short escape through vim_snprintf_safelen(). Generate the two hexadecimal digits of \u00xx directly, preserving the encoded output. Add coverage for all control escapes mixed with multibyte text across buffer growth, for both json_encode() and js_encode().
Before/after measurements for 1,000 calls to json_encode() on a 4,096-byte string (median of five runs, GCC -O2; baseline 1b405bb705, patched 0e6b0ddfb5):
| Input | Before | After | Time reduction |
|---|---|---|---|
Control characters: repeat("\x01", 4096) |
392.821 ms | 27.634 ms | 93.0% |
Mixed text: repeat(repeat('a', 63) .. "\x1b", 64) |
11.603 ms | 6.563 ms | 43.4% |
Plain ASCII: repeat('a', 4096) |
5.840 ms | 5.819 ms | 0.4% (essentially unchanged) |
These are focused microbenchmarks; baseline and patched binaries were alternated between runs and were not CPU-pinned.
Validation: make -C src -j4 completed without compiler warnings, all eight tests in test_json.vim passed, and git diff --check passed.
https://github.com/vim/vim/pull/21381
(2 files)
—
Reply to this email directly, view it on GitHub, or unsubscribe.
Triage notifications, keep track of coding agent tasks and review pull requests on the go with GitHub Mobile for iOS and Android. Download it today!
You are receiving this because you are subscribed to this thread.![]()
thanks
—
Reply to this email directly, view it on GitHub, or unsubscribe.
Triage notifications, keep track of coding agent tasks and review pull requests on the go with GitHub Mobile for iOS and Android. Download it today!
You are receiving this because you are subscribed to this thread.![]()