Compare commits

...

2 Commits

Author SHA1 Message Date
xavier2k6
9b66693cb8 GHA CI: Bump dependencies
* Bumped `Qt` to `6.9.1` on macOS/Windows
* Bumped `Qt` to `6.9.1` & `Boost` to `1.88.0` on `coverity-scan`

PR #22839.
2025-06-14 21:17:19 +08:00
Thomas Piccirello
406a389d7c WebUI: Improve performance of re-sorting table rows
This change drastically improves the performance of changing a table's sorted column. This performance is achieved through improved data structures, namely removing operations that repeatedly spliced an array. We also no longer iterate over a potentially large array.

On a torrent with ~50,000 files, re-rendering after a sort improves from ~20 seconds to 2 seconds.

PR #22827.
2025-06-14 21:06:33 +08:00
4 changed files with 36 additions and 29 deletions

View File

@@ -20,7 +20,7 @@ jobs:
matrix:
libt_version: ["2.0.11", "1.2.20"]
qbt_gui: ["GUI=ON", "GUI=OFF"]
qt_version: ["6.9.0"]
qt_version: ["6.9.1"]
env:
boost_path: "${{ github.workspace }}/../boost"

View File

@@ -106,7 +106,7 @@ jobs:
- name: Install Qt
uses: jurplel/install-qt-action@v4
with:
version: "6.9.0"
version: "6.9.1"
arch: win64_msvc2022_64
archives: qtbase qtsvg qttools
cache: true

View File

@@ -16,7 +16,7 @@ jobs:
matrix:
libt_version: ["2.0.11"]
qbt_gui: ["GUI=ON"]
qt_version: ["6.6.3"]
qt_version: ["6.9.1"]
env:
boost_path: "${{ github.workspace }}/../boost"
@@ -39,7 +39,7 @@ jobs:
- name: Install boost
env:
BOOST_MAJOR_VERSION: "1"
BOOST_MINOR_VERSION: "86"
BOOST_MINOR_VERSION: "88"
BOOST_PATCH_VERSION: "0"
run: |
boost_url="https://archives.boost.io/release/${{ env.BOOST_MAJOR_VERSION }}.${{ env.BOOST_MINOR_VERSION }}.${{ env.BOOST_PATCH_VERSION }}/source/boost_${{ env.BOOST_MAJOR_VERSION }}_${{ env.BOOST_MINOR_VERSION }}_${{ env.BOOST_PATCH_VERSION }}.tar.gz"

View File

@@ -858,42 +858,49 @@ window.qBittorrent.DynamicTable ??= (() => {
}
else {
const trs = [...this.getTrs()];
const trMap = new Map(trs.map(tr => [tr.rowId, tr]));
for (let rowPos = 0; rowPos < rows.length; ++rowPos) {
const rowId = rows[rowPos].rowId;
let tr_found = false;
for (let j = rowPos; j < trs.length; ++j) {
if (trs[j].rowId === rowId) {
tr_found = true;
if (rowPos === j)
break;
trs[j].inject(trs[rowPos], "before");
const tmpTr = trs[j];
trs.splice(j, 1);
trs.splice(rowPos, 0, tmpTr);
break;
}
const existingTr = trMap.get(rowId);
if (existingTr !== undefined) {
this.updateRow(existingTr, fullUpdate);
}
if (tr_found) { // row already exists in the table
this.updateRow(trs[rowPos], fullUpdate);
}
else { // else create a new row in the table
else {
const tr = this.createRowElement(rows[rowPos]);
// Insert
if (rowPos >= trs.length) {
tr.inject(this.tableBody);
trs.push(tr);
}
else {
tr.inject(trs[rowPos], "before");
trs.splice(rowPos, 0, tr);
}
// TODO look into using DocumentFragment or appending all trs at once for add'l performance gains
// add to end of table - we'll move into the proper order later
this.tableBody.appendChild(tr);
trMap.set(rowId, tr);
this.updateRow(tr, true);
}
}
// reorder table rows
let prevTr = null;
for (let rowPos = 0; rowPos < rows.length; ++rowPos) {
const { rowId } = rows[rowPos];
const tr = trMap.get(rowId);
const isInCorrectLocation = rowId === trs[rowPos]?.rowId;
if (!isInCorrectLocation) {
// move row into correct location
if (prevTr === null) {
// insert as first row in table
if (trs.length === 0)
this.tableBody.append(tr);
else
trs[0].before(tr);
}
else {
prevTr.after(tr);
}
}
prevTr = tr;
}
const rowPos = rows.length;
while ((rowPos < trs.length) && (trs.length > 0))