perf(rename): cache fileExists results in PropagateLocalRename::start#9999
Open
qoole wants to merge 1 commit intonextcloud:masterfrom
Open
perf(rename): cache fileExists results in PropagateLocalRename::start#9999qoole wants to merge 1 commit intonextcloud:masterfrom
qoole wants to merge 1 commit intonextcloud:masterfrom
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
PropagateLocalRename::startwas callingFileSystem::fileExistsrepeatedly across the same three paths in a row:originalFile: 2 callsexistingFile: 3 callstargetFile: 1 callEach call is a filesystem
stat. Cached the three results into localbools at the top of the function and reused them throughout.Bonus consistency win
A side effect of caching is that the
Q_ASSERTand the twoqCDebuglog lines below thefileAlreadyMovedcheck now use the same bool values thatfileAlreadyMovedwas 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)