Skip to content

Perf patches#7

Open
sharpobject wants to merge 5 commits into
0w0k:masterfrom
sharpobject:perf-patches
Open

Perf patches#7
sharpobject wants to merge 5 commits into
0w0k:masterfrom
sharpobject:perf-patches

Conversation

@sharpobject
Copy link
Copy Markdown
Contributor

No description provided.

Move cn map building (cardnames loop + Localization.mSource.mTerms loop +
Object.fromEntries) from inside i18n() to module load time. Add per-language
function cache so i18n('cn') returns the same function reference on repeated
calls, which is important for React.memo and useMemo dependency stability.
popupMatchSelectWidth={false} disables antd's virtual scrolling, forcing
all ~686 card options to render and be measured to determine popup width
on every interaction. Using a fixed pixel width (300) enables virtual
scrolling. This was the 0w0k#1 performance bottleneck (INP ~1,288ms → ~80ms).
Add .no-motion CSS class that sets animation-duration and
transition-duration to 0s. Apply popupClassName="no-motion" to all
TreeSelect components (card picker, talent picker, Five Elements Pure
Vase, Swordplay Talent) to eliminate slide/fade animation overhead.
@dnd-kit uses React context, causing all 16+ cards to re-render on every
drag frame. Replace with native HTML5 drag-and-drop using refs for drag
state and DOM class manipulation for visual feedback (.drag-source,
.drag-over). Zero React re-renders during drag.

Remove @dnd-kit/core, @dnd-kit/sortable, @dnd-kit/utilities from
package.json.
Pre-compute pinyin (full + first-letter) for all card names and talent
titles at useMemo time instead of calling getPinyin() on every keystroke
for every option. The cache is built once when the language changes and
reused across all filter calls.

Keeps upstream's heteronym support (heteronym: true, compact: true) in
the cached values.
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: e4f5d94fd8

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment on lines +48 to +52
draggable
onDragStart={onDragStart}
onDragOver={onDragOver}
onDrop={onDrop}
onDragEnd={onDragEnd}
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Restore touch drag support for card reordering

This change relies entirely on native HTML5 drag events (draggable + onDrag*) for reordering cards, but those events are not available on many touch-only browsers (notably iOS Safari), so mobile users can no longer reorder decks. The previous implementation explicitly wired touch behavior via TouchSensor; after this change there is no touch fallback path, so drag-and-drop becomes desktop-only.

Useful? React with 👍 / 👎.

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