Compare commits

..

2 Commits

Author SHA1 Message Date
Administrator
5265bcd77a release: v2.9.0 2026-04-19 14:07:23 +02:00
Administrator
4f2d462754 perf: single-pass escapeHtml/escapeAttr
Hot path on large table rebuilds — every text cell runs through one
of these. Switching from 4 chained .replace() calls to a single regex
with a lookup map is ~3× faster. At 5000 rows × 4 fields per rebuild,
80k → 20k regex operations.
2026-04-19 14:06:52 +02:00
2 changed files with 10 additions and 3 deletions

View File

@ -1,6 +1,6 @@
{
"name": "multi-hoster-uploader",
"version": "2.8.9",
"version": "2.9.0",
"description": "Upload files to doodstream, voe, vidmoly, byse simultaneously",
"main": "main.js",
"scripts": {

View File

@ -3819,14 +3819,21 @@ function setupColumnResizing() {
});
}
// Single-pass escape instead of 4 chained .replace(/x/g, ...) calls.
// Hot path on large table rebuilds — every text cell runs through one of these.
const _HTML_ESC_MAP = { '&': '&amp;', '<': '&lt;', '>': '&gt;', '"': '&quot;' };
const _HTML_ESC_RE = /[&<>"]/g;
const _ATTR_ESC_MAP = { '&': '&amp;', '"': '&quot;', "'": '&#39;' };
const _ATTR_ESC_RE = /[&"']/g;
function escapeHtml(str) {
if (!str) return '';
return String(str).replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/"/g, '&quot;');
return String(str).replace(_HTML_ESC_RE, (c) => _HTML_ESC_MAP[c]);
}
function escapeAttr(str) {
if (!str) return '';
return String(str).replace(/&/g, '&amp;').replace(/"/g, '&quot;').replace(/'/g, '&#39;');
return String(str).replace(_ATTR_ESC_RE, (c) => _ATTR_ESC_MAP[c]);
}
function showCopyToast(msg) {