Repository navigation
perf: 大きなパケットの表示で固まらないよう RawTextPane を RSyntaxTextArea に置き換える - #278
Merged
funa-tk merged 4 commits intoNov 12, 2026
Merged
Conversation
文字属性の書き換えは大きなデータで遅く、表示部品が JTextPane であることにも依存していた。見えている範囲だけ背景を塗る Highlighter に変え、後続のコミットで RawTextPane を差し替える準備とする。 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Diff 画面と同じく、文字属性の書き換えをやめて Highlighter で背景を塗る。強調範囲は緑の太字から薄緑の背景になる。長い 1 行に多くのハイライトが乗ると描画が極端に遅くなる(10 万文字の 1 行に 2400 件で 1 回 10 秒以上)ので、一致の色付けは 200 件までにし、件数の表示は全件を数える。key=value の文字色は Highlighter で表せないので外し、後続のコミットで字句解析器に移す。 ほぼ書き直しになるので Kotlin に移した。Kotlin から Lombok が生成するメソッド(Range.of など)を呼べるよう、Kotlin の Lombok プラグインを加えている。 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
描画する行だけを色付けする RSyntaxTextArea の依存と、その上で動く PacketTokenMaker を加える(まだどこからも使わない)。HTTP ヘッダとボディを区別し、ボディが JSON か SSE なら JSON として、それ以外は key=value を色付けする。 標準の TokenMakerBase はトークンの置き場を 10 個ずつしか広げず、改行のない巨大な JSON で解析が 2 乗の時間になる(約 1MB で 7 秒)。そのため TokenMaker を直接実装し、置き場を倍々で広げる。key=value の判定も、java.util.regex では = のない長い行(base64 など)で 2 乗の時間になるので、正規表現を使わず 1 回の走査で行う。ライセンス(BSD-3-Clause)は LICENSES に同梱した。 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
JsonSyntaxHighlighter が Document に大量の文字属性を書き込むため、約 290KB の JSON の表示に 67 秒かかっていた。RawTextPane を RSyntaxTextArea の上に作り直して色付けを PacketTokenMaker に任せ、0.2 秒程度にした。JsonSyntaxHighlighter は削除し、RawTextPane は Kotlin に移した。 パケットを意図せず書き換えうる編集補助は止めた。括弧の自動補完や選択範囲のドラッグ移動を無効にし、キー操作は標準的な編集操作だけを残す(Cmd+D の行削除、INSERT の上書きモードなどは外し、TAB は旧実装と同じく選択範囲をタブ 1 文字で置き換える)。選択中に括弧や引用符を打つと囲む動作だけを加えた。見た目の変化として、RawTextPane を使うすべての画面(Diff、全データ、Bulk Sender など)に JSON と key=value の色が付く。 RawTextPaneTest は、描画とクリップボードを使うもの以外は画面のない CI でも動く。 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
mayo031042
force-pushed
the
perf/raw-text-pane-rsyntaxtextarea
branch
from
November 10, 2026 07:43
31a4471 to
47f7d51
Compare
funa-tk
approved these changes
Nov 12, 2026
funa-tk
left a comment
Contributor
There was a problem hiding this comment.
ありがとうございます!
昔から問題だったので助かります。
1 task done
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
長さが 10 万文字を超えるパケット(特に改行のない JSON)を表示すると、UI が長い時間固まっていました。約 290KB の JSON では、表示までに 67 秒かかっていました。原因は、
JsonSyntaxHighlighterとSearchBoxが、JTextPaneの Document にトークンごとの文字属性を書き込んでいたことです。RawTextPaneを RSyntaxTextArea(BSD-3-Clause)の上に作り直し、色付けは描画する行だけを字句解析する方式にしました。同じ JSON の表示は 0.2 秒程度になります。検索、強調表示、Diff の色付けも、文字属性ではなくHighlighter(背景色)で行います。大きく書き直したRawTextPane、SearchBox、PacketTokenMakerは Kotlin で書いています。コミットは 4 つに分けています:
RawTextPaneを差し替える挙動の変化
RawTextPaneを使うすべての画面(Diff、全データ、Bulk Sender など)で、JSON と key=value に色が付きます。確認したこと
./gradlew spotlessCheck testが通ることを確認しました。PacketTokenMakerTest、RawTextPaneTest、SearchBoxTestを追加しました。=のない長い行で、解析の時間が 2 乗にならないことを確かめるテストを含みます。RawTextPaneTestのうち、描画とクリップボードを使う 2 つは、画面のない環境(CI)ではスキップします。手元のアプリで、大きな JSON の表示と編集、検索、Diff を確認しました。
By placing an "x" in the box, I hereby understand, accept and agree to be bound by the terms and conditions of the Contribution License Agreement.