-
Notifications
You must be signed in to change notification settings - Fork 403
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
iox-#1431: Add unsafe_raw_access to iox::string #2093
iox-#1431: Add unsafe_raw_access to iox::string #2093
Conversation
Codecov Report
Additional details and impacted files@@ Coverage Diff @@
## master #2093 +/- ##
==========================================
+ Coverage 80.28% 80.29% +0.01%
==========================================
Files 417 417
Lines 16121 16128 +7
Branches 2250 2250
==========================================
+ Hits 12942 12950 +8
Misses 2384 2384
+ Partials 795 794 -1
Flags with carried forward coverage won't be shown. Click here to find out more.
|
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.
For traceability reasons it might be better to have this PR to be part of #1431 which is more related to strings than #2040. Maybe we can make #2040 kind of a meta issue and have more specific issues for the tasks which need to be done. There will be a few preparatory PRs like this until everything is in place to finally get rid of the runtime allocations and not relying on small object optimizations to not have them.
@elBoberido if you prefer I can force-push the commit, but the branch style name will be the same, otherwise, I can close this PR and reopen another with the correct branch identification (using 1431 instead of 2040). Yes, maybe is better to create a sort of tasklist for the 2040 |
I would be fine with a force push and keeping the branch name with 2040 for this PR. The most important part for traceability is what git blame shows on the respective line and to easily find the corresponding issue where the line was changed. The branch name is not that important and we must not be more catholic than the pope :) |
Btw, the clang-tidy check fails. You can run it locally with |
I see, the
|
I might end up making For the other issue, in theory we decided to deactivated the rule for the time being but actually forgot to actually do it. I think the reason we forgot about it was that it did not show up in the production files we scan. If It could look like this and could live in struct BufferInfo {
uint64_t used_size{0};
uint64_t total_size{0};
}; It would be a bit different than what we have now since it supplies the whole buffer size, including the space for the null-termination, but this would make it easier to work with functions like What do you think? |
If possible, I suggest changing the clang-tidy rules, almost to set at 3 the I think this workaround increases the code complexity because when I see the method prototype, I can't understand all parameters, I need to find and read the |
@lucabart97 if it is only for convenience I would take the more safe approach. Our long term plan is to use specific types as much as possible to elevate small oversights to compile time failures. With autocompletion from the clang LSP it also just shows The reason you understand the current signature is because you just wrote it and it is fresh in your mind but these things get blurry and in a few months it is not anymore as clear as now. User which are new to the API have to look at the documentation anyway or their IDE will tell them the meaning of the members of the struct. Btw, have you already seen comments like this https://www.reddit.com/media?url=https%3A%2F%2Fi.redd.it%2Fhwqj7yx9vm211.jpg? Only slightly related but when writing about fading memories I remembered that I wrote a similar comment to something which was fully clear when I wrote the code :) |
f9e3b0a
to
c9a8d8f
Compare
@elBoberido got it I add
Tell me your feedback :) |
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.
Almost there. This can soon be merged :)
Oh, and there is another formalism. If there wouldn't be other changes then it could be left as is but since you have to commit anyway could you capitalize the commit message to |
c9a8d8f
to
6672a5c
Compare
@elBoberido I got your comments and I have updated the code/commit message! |
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.
Almost there. Just two additional tests.
6672a5c
to
036423d
Compare
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.
Great. Thanks for your patience :)
Once the CI has run this can be merged
Oh, just notice that there is an issue on the CI. It seems the new tests have an unused |
036423d
to
0d4220a
Compare
@elBoberido |
Oh no, now Windows complains. You can easily find the error by searching for |
@elBoberido |
@lucabart97 I'm not quite sure. If it isn't an aftereffect on the first error it might be a missing |
0d4220a
to
15d633b
Compare
Or maybe there is a weird type conversion for |
Ok, on mac-os the capture of Let's see if Windows passes or not, maybe can be a weird type conversion for |
Implement a method that provides direct access to the string's underlying pointer. This allows data to be written directly to the string, eliminating the need for copies. The string's length is checked on each call to ensure the null terminator is in the correct position. Signed-off-by: Luca Bartoli <[email protected]>
Welcome to the hell known as Windows support 😅 It seems clang based toolchains consider the capturing of |
15d633b
to
79cd989
Compare
I hope it will be fine! (Windows 👎) |
I've a good feeling now :) |
Implement a method that provides direct access to the string's underlying pointer. This allows data to be written directly to the string, eliminating the need for copies. The string's length is checked on each call to ensure the null terminator is in the correct position.
Pre-Review Checklist for the PR Author
iox-123-this-is-a-branch
)iox-#123 commit text
)task-list-completed
)iceoryx_hoofs
are added to./clang-tidy-diff-scans.txt
Notes for Reviewer
Checklist for the PR Reviewer
iceoryx_hoofs
have been added to./clang-tidy-diff-scans.txt
Post-review Checklist for the PR Author
References
cxx::string
#1431