Description
Gitea Version
All up to 1.16.0+dev-293-ge8574f2f7
Operating System
All
Browser Version
Independent of Browser
Can you reproduce the bug on the Gitea demo site?
Yes
Description
Currently, the data-new-comment-url
variable needed for the New review comment
(+
) button is calculated per button - see the code sample below that shows the code for one such button.
<a class="ui primary button add-code-comment add-code-comment-right" data-path="test2.txt" data-side="right" data-idx="3" data-new-comment-url="https://try.gitea.io/delvh/kanban-test/pulls/10/files/reviews/new_comment">
…
</a>
This, however, is unnecessary, as all these buttons point to exactly the same URL.
So, it would suffice to set this one time globally when rendering the template.
This would speed up diff generation, file sending, and also client-side processing time.
Especially large PRs benefit disproportionally from this. This is simply due to having a higher ratio of buttons compared to the rest of the page. This is even more true when those big PRs change lines instead of adding completely new lines/ deleting old lines, as then the button will be generated twice per line.
Benchmark
I've tested on one PR that had 3200 lines added and almost none changed.
On that PR, there were 4666 instances of this unnecessary declaration.
The size that was unnecessarily generated was about 435KB, or 6.5% of the whole size of the page (6.7MB).
Here, you can see that this simple fix can improve performance by up to 7%, which definitely is worth fixing.
Screenshots
See code sample above.