Attempt to fix the perf issue in selectattr | first filter (#209)

Replace O(n²) Jinja2 filter searches with an O(1) dictionary lookup.
This commit is contained in:
KnugiHK
2026-04-05 23:01:21 +08:00
parent a0719bc2bf
commit 1dc1b7511f
2 changed files with 7 additions and 3 deletions

View File

@@ -355,7 +355,7 @@
{% endif %}
</p>
</div>
{% set replied_msg = msgs | selectattr('key_id', 'equalto', msg.reply) | first %}
{% set replied_msg = msg_map(msg.reply) %}
{% if replied_msg and replied_msg.media == true %}
<div class="flex-shrink-0">
{% if "image/" in replied_msg.mime %}
@@ -461,7 +461,7 @@
{% endif %}
</p>
</div>
{% set replied_msg = msgs | selectattr('key_id', 'equalto', msg.reply) | first %}
{% set replied_msg = msg_map(msg.reply) %}
{% if replied_msg and replied_msg.media == true %}
<div class="flex-shrink-0">
{% if "image/" in replied_msg.mime %}