Skip to content

perf(rename): cache fileExists results in PropagateLocalRename::start#9999

Open
qoole wants to merge 1 commit intonextcloud:masterfrom
qoole:perf/local-rename-batch
Open

perf(rename): cache fileExists results in PropagateLocalRename::start#9999
qoole wants to merge 1 commit intonextcloud:masterfrom
qoole:perf/local-rename-batch

Conversation

@qoole
Copy link
Copy Markdown

@qoole qoole commented May 7, 2026

Summary

PropagateLocalRename::start was calling FileSystem::fileExists repeatedly across the same three paths in a row:

  • originalFile: 2 calls
  • existingFile: 3 calls
  • targetFile: 1 call

Each call is a filesystem stat. Cached the three results into local bools at the top of the function and reused them throughout.

Bonus consistency win

A side effect of caching is that the Q_ASSERT and the two qCDebug log lines below the fileAlreadyMoved check now use the same bool values that fileAlreadyMoved was computed from. Previously, if filesystem state changed between the original computation and the assert/log calls (unlikely but possible under aggressive renames), the log line and the assert could disagree. Now they're guaranteed consistent.

No behavioral change.

Checklist

AI (if applicable)

  • The content of this PR was partly or fully generated using AI

PropagateLocalRename::start was calling FileSystem::fileExists up to
five times across the same three paths in a row. Each call is a
filesystem stat. Cache the three results into local bools and reuse
them.

Side benefit: the Q_ASSERT and the two qCDebug log lines now match
the bool values used in fileAlreadyMoved, eliminating the chance of
the assert and the log disagreeing if the filesystem state changes
mid-function.

Signed-off-by: Qoole <2862661+qoole@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant