You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
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.
The text was updated successfully, but these errors were encountered:
- Resolvesgo-gitea#17167
- Don't generate the same `data-comment-url` over and over for each
edited LOC.
- Set `data-comment-url` for top-table of diff output.
Data for diff with 2.5K additons 0 edits 0 deletions:
```
No-patch:
Split: 2.82 MB
Unified: 2.37 MB
Patch:
Split: 2.59 MB (-8.2%)
Unified: 2.15 MB (-9.3%)
```
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 theNew review comment
(+
) button is calculated per button - see the code sample below that shows the code for one such button.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.
The text was updated successfully, but these errors were encountered: