Skip to content

Conversation

@abimaelmartell
Copy link
Member

@abimaelmartell abimaelmartell commented Jan 3, 2026

Identified and optimized performance bottlenecks in GitHubFlavored table processing.

Bottlenecks Identified

  1. isHeadingRow() — Line 155: parent.Children().First().IsSelection(s)
  • Time: 9.19s (36.86% of total)
  • Issue: Created new Selection objects and compared them for every row
  • Fix: Compare node pointers directly, skipping text nodes
  1. getCellContent() — Line 179: Linear search through parent's children
  • Time: 90ms per call (called for every cell)
  • Issue: O(n) search to find cell index
  • Fix: Direct node pointer comparison to check if first child
  1. isHeadingRow() — Line 149: Iterating through all children
  • Issue: No early exit when non-TH found
  • Fix: Break early when a non-TH cell is found

Existing tests are passing, i will add a test with a similar test case that was taking the 8s

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR optimizes performance in the Table plugin by replacing expensive goquery operations with direct node pointer comparisons and early-break logic. The changes focus on reducing computational overhead when processing HTML table structures during markdown conversion.

Key Changes:

  • Added early-break optimization when checking if table row cells are all TH elements
  • Replaced parent.Children().First().IsSelection(s) with direct node pointer comparison in isHeadingRow
  • Replaced linear search through children with direct node pointer comparison in getCellContent

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@amplitudesxd amplitudesxd self-requested a review January 3, 2026 16:04
@abimaelmartell abimaelmartell merged commit c035ce0 into master Jan 3, 2026
1 check 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.

3 participants