Commit d49ccc1
committed
Qt: cache root index in FileSystemProxyModel::filterAcceptsRow
The proxy model's filterAcceptsRow is called once per (row, parent)
pair the source QFileSystemModel surfaces, which can run into the
tens of thousands during a directory load, sort, or filter pass on
a populous tree. The original implementation resolved the source
model's root path to a QModelIndex via sm->index(sm->rootPath()) on
every single call - cheap individually, but it adds up.
The root path itself only changes when the user navigates, so cache
both the path and its resolved index on the proxy. On each call,
compare the cached path against the current one (a QString equality
check, much cheaper than re-walking the model); refresh on mismatch.
No behaviour change.1 parent 146ac2e commit d49ccc1
2 files changed
Lines changed: 28 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1386 | 1386 | | |
1387 | 1387 | | |
1388 | 1388 | | |
1389 | | - | |
| 1389 | + | |
| 1390 | + | |
| 1391 | + | |
| 1392 | + | |
| 1393 | + | |
| 1394 | + | |
| 1395 | + | |
| 1396 | + | |
1390 | 1397 | | |
1391 | 1398 | | |
1392 | | - | |
1393 | | - | |
1394 | | - | |
| 1399 | + | |
| 1400 | + | |
| 1401 | + | |
| 1402 | + | |
| 1403 | + | |
| 1404 | + | |
| 1405 | + | |
| 1406 | + | |
| 1407 | + | |
| 1408 | + | |
1395 | 1409 | | |
1396 | 1410 | | |
1397 | 1411 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
386 | 386 | | |
387 | 387 | | |
388 | 388 | | |
| 389 | + | |
| 390 | + | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
| 394 | + | |
| 395 | + | |
| 396 | + | |
| 397 | + | |
| 398 | + | |
389 | 399 | | |
390 | 400 | | |
391 | 401 | | |
| |||
0 commit comments