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.
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve
CreateDirectory
on Windows #66754Improve
CreateDirectory
on Windows #66754Changes from 13 commits
8ce1a96
de9e3a9
a0b5388
e43967a
d6b06b3
31961a4
12d7729
6faa0e1
bf0e715
7fc97aa
920bf49
8cfca86
b9e4754
8fb6ecb
5bc0806
c926642
378a6f7
61af4d3
056c9b9
cb6a732
ff116e4
bc22603
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Adding these "Slim" functions seems to be an attempt to improve throughput, but the perf results shared don't really show a throughput improvement. Seems like these changes should be reverted?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The FindFirstFilePrefixed path here is the rare case, right? (<1%) Where the file is locked.
Given that, I don't think you're really saving anything by ensuring you only call EnsureExtendedPrefixIfNeeded once. I would reverse this and leave GetFileAttributesExPrivate private. That avoids creating a way for future code to accidentally call GetFileAttributesEx without prefixing. And it leaves this code a bit simpler.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was marked resolved but I don't see the feedback addressed. Was it commented on somewhere else?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why are the changes in this file necessary?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like this method can be turned into a single line and produce the same code:
https://sharplab.io/#v2:EYLgxg9gTgpgtADwGwBYA0AXEBDAzgWwB8ABAJgEYBYAKGIGYACMhgYQYG8aHufuBLAHYYYUAdgA2TckgbAIESQEEAFMXIAGBgAdsGABYBKLrx6dqJi0wDs23XoDaO/QDoAMjAEBzfQzgNyALoMALzBDADkEQyEhLb6jnZuHt56vv5BoRHO4QDcxhYAvvkMxbyCwqISUjJyCgwAQqoacYalpm0WYHrYUAxgIS0JLu5ePn6BeeaWvMQ2/ZmRkTF9IWHh2ZPTRdQFQA===
(checked both 32 and 64 bit)
Given that, I suggest inlining
path[path.Length - 1] == ' ' || path[path.Length - 1] == '.'
into EndsWithPeriodOrSpace and EnsureExtendedPrefixIfNeeded. This eliminates a method that isn't really useful, but also is a trap for anyone in future that calls it without checking the length. It's perfectly clear when inlined.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
BTW, we have slightly changed the behavior here. Previously EndsWithPeriodOrSpace would return false for " " and now it will return true. Is that OK? I'm actually not sure.
If it is, then EndsWithPeriodOrSpace could be even less code:
return path.Length > 0 && (path[path.Length - 1] == ' ' || path[path.Length - 1] == '.');
generates less code. But, I don't suggest changing that here.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We have only two direct usages, which could break:
PathInternal.EnsureExtendedPrefixIfNeeded
and
FileSystemInfo.NormalizedPath
@tmds @jozkee Are you comfortable with this change (Tests are passing, but behavior might slightly change)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@deeprobin I'd like to err on the side of caution here and avoid the subtle behavior change.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why are the changes in this file necessary?