-
Notifications
You must be signed in to change notification settings - Fork 13.4k
Use raw pointer for NUL-terminated file location with #[track_caller]
#142579
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
Conversation
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
I don't think that this is really a disadvantage, as the compiler is perfectly able to remove an unnecessary call to |
There is still a plan to make |
We discussed this in the libs-api meeting. There wasn't much enthusiasm for this change. Part of the reason is that we might still make Because of these reasons, I'm closing this PR. |
Thanks! Marking the feature as implementation complete in the tracking issue. |
As a follow-up to the
Location::file_with_nul
ACP, I'm filing this PR to ask a question for T-libs-api:This question is listed as an unresolved question in the ACP and tracking issue.
The main advantage of a raw pointer is that creating a
&CStr
requires knowing the length. This means that if we reintroduce the optimization from #117431 of not storing the length anywhere, callers offile_with_nul
will make an unnecessary call tostrlen
when they just need to pass the pointer into C code. The main disadvantage is that using the raw pointer is unsafe.Tracking issue: #141727