Avoid quadratic slowdown in markdown rendering
commit05d91c021babbfadfd7ad4d090d26c3dd7e37078
authorMichael Thomas <mjt@fb.com>
Wed, 11 May 2022 17:47:48 +0000 (11 10:47 -0700)
committerFacebook GitHub Bot <facebook-github-bot@users.noreply.github.com>
Wed, 11 May 2022 17:47:48 +0000 (11 10:47 -0700)
tree3a16e058e53a8110e0af6308f8267595ce007443
parent158d256c7ae50c527298197458769d430ccf4b0f
Avoid quadratic slowdown in markdown rendering

Summary:
The `markdown_lite` parser is using left-associated list append; since the left hand operand is itself the result of a list append, we end up traversing it again and end up with a quadratic slowdown. In pathological cases in the linked tasks, where we have shapes with over 4000 fields(!), this brings rendering to a grinding halt.

This diff replaces append with cons & rev.

Reviewed By: Wilfred, hgoldstein

Differential Revision: D36314037

fbshipit-source-id: ce7f58f9f34292bd2c9bdbcc354edf8416cfca3f
hphp/hack/src/errors/markdown_lite.ml