Skip to content

Commit

Permalink
main: switch details_link to a simple tag
Browse files Browse the repository at this point in the history
An inclusion_tag renders a template on every request, for the glibc page
this meant calling Template.render() 7529 times(!) and loading ~ 5
seconds on my AMD Ryzen 7 5700X 8 Core. With this change we now do 3629
Template.render calls in 500 ms.
  • Loading branch information
jelly committed Jul 20, 2024
1 parent d01193a commit 8d07c92
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
6 changes: 4 additions & 2 deletions main/templatetags/details_link.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

from django import template
from django.conf import settings
from django.utils.html import format_html

from main.templatetags import pgp
from main.utils import gitlab_project_name_to_path
Expand All @@ -18,9 +19,10 @@ def link_encode(url, query):
return "%s?%s" % (url, data)


@register.inclusion_tag('packages/details_link.html')
@register.simple_tag
def details_link(pkg):
return {'pkg': pkg}
link = '<a href="%s" title="View package details for %s">%s</a>'
return format_html(link % (pkg.get_absolute_url(), pkg.pkgname, pkg.pkgname))


@register.simple_tag
Expand Down
1 change: 0 additions & 1 deletion templates/packages/details_link.html

This file was deleted.

0 comments on commit 8d07c92

Please sign in to comment.