Skip to content

Improve string replace performance - #1737

Merged
cyanzhong merged 1 commit into
mainfrom
develop
Sep 9, 2026
Merged

Improve string replace performance#1737
cyanzhong merged 1 commit into
mainfrom
develop

Conversation

@cyanzhong

Copy link
Copy Markdown
Contributor

No description provided.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟢 Approval recommended

The changes are small, consistent with the intended performance goal, and the updated test adds a concrete guardrail for the placeholder assumptions the optimization relies on.

Pull request overview

This PR targets string replacement hotspots by making replacements more explicit/literal and by avoiding unnecessary scans of large injected JSON when generating the editor’s index.html.

Changes:

  • Use literal string replacement options for line-break sanitization when copying pasteboard content.
  • Optimize index.html placeholder substitution by replacing the later placeholder first and limiting replacements to a single occurrence.
  • Strengthen the CoreEditor build test to assert placeholder uniqueness and ordering.
File summaries
File Description
MarkEditMac/Modules/Sources/AppKitExtensions/Foundation/NSPasteboard+Extension.swift Forces literal replacements during line-break normalization.
MarkEditCore/Sources/EditorIndexHtml.swift Reorders and bounds placeholder replacement to reduce scanning work.
MarkEditCore/Sources/EditorImageLoader.swift Refactors formatting only (no behavioral change).
CoreEditor/test/build.test.ts Validates placeholders occur once and appear in the expected order.
Review details
  • Files reviewed: 4/4 changed files
  • Comments generated: 0
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@cyanzhong
cyanzhong merged commit 45247e0 into main Sep 9, 2026
2 checks passed
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