Skip to content

Optimize outline parsing allocations and fast-path scalar properties - #148

Open
tiensonqin wants to merge 1 commit into
masterfrom
codex/improve-outliner-parse-performance
Open

Optimize outline parsing allocations and fast-path scalar properties#148
tiensonqin wants to merge 1 commit into
masterfrom
codex/improve-outliner-parse-performance

Conversation

@tiensonqin

Copy link
Copy Markdown
Collaborator

Motivation

  • Reduce allocations and work during outline parsing by reusing the strings produced by String.split_on_char instead of mapping and allocating new strings.
  • Avoid computing line_starts when only an outline parse is requested via config.parse_outline_only.
  • Avoid running the full inline grammar for property values that cannot contain references to improve performance on common scalar Logseq properties.

Description

  • In lib/syntax/md_outline.ml replace Array.of_list (List.map rstrip_cr raw_lines) with Array.of_list raw_lines and Array.iteri to only replace CRLF lines in place, reusing the original allocations for LF inputs.
  • Make line_starts allocation conditional on config.parse_outline_only so the array is not built when not needed.
  • In lib/syntax/property.ml add a cheap may_have_reference scan for '#', '[', or '(' and return early when none are present, and keep the existing quoted-string check; only run the full Inline.parse when a reference is plausible.

Testing

  • Ran the project test suite with dune runtest, and the tests completed successfully.
  • Performed quick parsing smoke tests on sample outlines and property lines to verify no regressions in outline extraction and property reference detection.

Codex Task

perf: reduce outline line metadata allocations
Copilot AI lite review requested due to automatic review settings August 30, 2026 06:47

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@CLAassistant

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants