_qstags: Let's try a simpler substitution for speed

This commit is contained in:
Stig-Ørjan Smelror 2024-02-24 19:32:44 +01:00
parent d3ccb64a73
commit 81b22db011

18
qsgen2
View File

@ -1284,13 +1284,17 @@ function _qstags() {
"#LT" "<" "#GT" ">" "#NUM" "#" "#LT" "<" "#GT" ">" "#NUM" "#"
) )
for qstag html (${(kv)qstags}) #for qstag html (${(kv)qstags})
do # do
# Escape tag for regex use # # Escape tag for regex use
local escapedTag=$(printf '%s' "$qstag" | sed 's/[].\[^$*]/\\&/g') # local escapedTag=$(printf '%s' "$qstag" | sed 's/[].\[^$*]/\\&/g')
if [[ "$content" =~ "$escapedTag" ]]; then # if [[ "$content" =~ "$escapedTag" ]]; then
content=${content//($qstag)/$html} # content=${content//($qstag)/$html}
fi # fi
#done
for qstag html (${(kv)qstags}); do
# Direct replacement without regex check
content=${content//${qstag}/${html}}
done done
echo "${content}" echo "${content}"