-
Notifications
You must be signed in to change notification settings - Fork 32
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
Code safety/modernization #234
Open
snej
wants to merge
5
commits into
master
Choose a base branch
from
lifetimebound
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Conversation
This file contains 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
snej
force-pushed
the
lifetimebound
branch
2 times, most recently
from
August 5, 2024 19:46
433782e
to
a8a9a47
Compare
Nice! Did not know this existed, good to see a little extra safety in C++. |
- Removed obsolete/unused MUST_USE_RESULT - Changed LITECORE_UNUSED to be the standard C++17 [[maybe_unused]] and commented that we should stop using the macro - Added LIFETIMEBOUND Removed LITECORE_UNUSED, FLEECE_UNUSED Replaced with standard [[maybe_unused]]
Some slice code cleanup, removing C++11/C++14 shims - Added `data()` and `size_bytes()` methods to slice types, like those in std::span. (Can't add `size()` because it conflicts with a data member.) This is an incremental step toward moving to `span`, or at least making the `buf` and `size` fields private. - Likewise, added `data()`, `size_bytes()` to FLSlice and FLSliceResult, as well as `empty()` and `operator bool`. - Removed obsolete `sliceHash`. - Removed conditional support for `std::string_view`, unnecessary since we require C++17. - Removed `constexpr14` which was only useful when we supported C++11. - Added default initializers to slice member variables instead of initializing in the default constructor. - Use `= default` for default constructors.
- Make Value, Array, Dict trivially copyable: this allows instances to be passed in a register instead of on the stack in some ABIs, such as ARM64, which is more efficient. (The fix is to remove the custom operator= methods, which are unnecessary.) - Made operator==, operator!= methods const. - Made move constructors/assignment `noexcept`, which helps collections generate more optimal code. - Don't pass `alloc_slice` or `string` by value.
callumbirks
approved these changes
Sep 9, 2024
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.
No description provided.