-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Remove most preemptive checks from GetFullPath #16478
Conversation
- Remove all path validity checks outside of
- Null
- Embedded null
- Empty or all spaces (effectively empty)
- Remove PathStartSkip helper
- Use span overloads for StringBuffer usage
- Clean up some comments
| int rootLength = PathInternal.GetRootLength(outputBuffer); | ||
| bool isDevice = PathInternal.IsDevice(outputBuffer); | ||
|
|
||
| StringBuffer inputBuffer = new StringBuffer(0); |
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 does it make sense for ValueStringBuilder to grow to absorb the function of STringBuffer ?
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.
I called out that I intend to look into that in the PR comments above. It is definitely worth investigating, I just didn't want to make this change too complicated.
| if (fullPath.Length == path.Length && fullPath.StartsWith(path)) | ||
| { | ||
| // If we have the exact same string we were passed in, don't bother to allocate another string from the StringBuilder. | ||
| // If we have the exact same string we were passed in, don't bother to allocate another string from the StringBuffer. |
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.
Nit, no need to fix, but if code always returns out of a conditional block
if (...)
{
// ..
return ...;
}
else
{
. ...
}I think it's easier to read if you avoid the indent/braces ie
if (...)
{
// ..
return ...;
}
. ...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.
I agree. I usually early out.
| _length = 0; | ||
| } | ||
|
|
||
| public static implicit operator ReadOnlySpan<char>(StringBuffer stringBuffer) |
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.
I think it would be better to make the cast explicit via AsReadOnlySpan method. StringBuffer is not immutable, and so you have to be careful about for how long you are going to use the Span.
| _length = 0; | ||
| } | ||
|
|
||
| public static explicit operator ReadOnlySpan<char>(StringBuffer stringBuffer) |
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.
Nit: We have been using AsReadOnlyMethod() in other similar places:
https://github.com/dotnet/corefx/blob/master/src/Common/src/CoreLib/System/Collections/Generic/ValueListBuilder.cs#L46
https://github.com/dotnet/corefx/pull/27250/files#diff-1a641bcf15d0f95ae2b8a25f157ecd51R71
Updates for dotnet/coreclr#16478
Updates for dotnet/coreclr#16478
|
Now have the test PR up. dotnet/corefx#27348. |
Updates for dotnet/coreclr#16478
* Update tests for Path changes Updates for dotnet/coreclr#16478 * Add back Unix active issue (wishful thinking that this would get the same error on Unix) * Address feedback
|
Tests have been updated in CoreFX. (#27348) |
* Removing the colon block that tosses out paths that are not device path.
Fixes: #26359
* Striping 2nd and 3rd args of PathHelper.Normalize
* Build on Maryam's changes
- Remove all path validity checks outside of
- Null
- Embedded null
- Empty or all spaces (effectively empty)
- Remove PathStartSkip helper
- Use span overloads for StringBuffer usage
- Clean up some comments
* Address feedback
* Tweak to match other AsSpan methods
Signed-off-by: dotnet-bot <[email protected]>
* Removing the colon block that tosses out paths that are not device path.
Fixes: #26359
* Striping 2nd and 3rd args of PathHelper.Normalize
* Build on Maryam's changes
- Remove all path validity checks outside of
- Null
- Embedded null
- Empty or all spaces (effectively empty)
- Remove PathStartSkip helper
- Use span overloads for StringBuffer usage
- Clean up some comments
* Address feedback
* Tweak to match other AsSpan methods
Signed-off-by: dotnet-bot <[email protected]>
* Removing the colon block that tosses out paths that are not device path.
Fixes: #26359
* Striping 2nd and 3rd args of PathHelper.Normalize
* Build on Maryam's changes
- Remove all path validity checks outside of
- Null
- Embedded null
- Empty or all spaces (effectively empty)
- Remove PathStartSkip helper
- Use span overloads for StringBuffer usage
- Clean up some comments
* Address feedback
* Tweak to match other AsSpan methods
Signed-off-by: dotnet-bot-corefx-mirror <[email protected]>
* Removing the colon block that tosses out paths that are not device path.
Fixes: #26359
* Striping 2nd and 3rd args of PathHelper.Normalize
* Build on Maryam's changes
- Remove all path validity checks outside of
- Null
- Embedded null
- Empty or all spaces (effectively empty)
- Remove PathStartSkip helper
- Use span overloads for StringBuffer usage
- Clean up some comments
* Address feedback
* Tweak to match other AsSpan methods
Signed-off-by: dotnet-bot-corefx-mirror <[email protected]>
* Removing the colon block that tosses out paths that are not device path.
Fixes: #26359
* Striping 2nd and 3rd args of PathHelper.Normalize
* Build on Maryam's changes
- Remove all path validity checks outside of
- Null
- Embedded null
- Empty or all spaces (effectively empty)
- Remove PathStartSkip helper
- Use span overloads for StringBuffer usage
- Clean up some comments
* Address feedback
* Tweak to match other AsSpan methods
Signed-off-by: dotnet-bot <[email protected]>
* Update tests for Path changes Updates for dotnet/coreclr#16478 * Add back Unix active issue (wishful thinking that this would get the same error on Unix) * Address feedback
* Update tests for Path changes Updates for dotnet/coreclr#16478 * Add back Unix active issue (wishful thinking that this would get the same error on Unix) * Address feedback Commit migrated from dotnet/corefx@92afa6e
* Update tests for Path changes Updates for dotnet/coreclr#16478 * Add back Unix active issue (wishful thinking that this would get the same error on Unix) * Address feedback Commit migrated from https://github.com/dotnet/corefx/commit/dotnet/runtime@92afa6ec21817739ebf45cd66b4569a03b54d4c0 Commit migrated from dotnet/runtime@973cec3
Builds on #16311. This makes behavior much more consistent cross-plat and allows currently blocked scenarios (notably accessing Unix volumes from Windows).
I've marked this as no merge until I get the test changes finished/checked-in for CoreFX. I'll link the PR when it is up.
Note that I'm going to investigate: