Skip to content
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
wants to merge 5 commits into
base: master
Choose a base branch
from
Open

Code safety/modernization #234

wants to merge 5 commits into from

Conversation

snej
Copy link
Contributor

@snej snej commented Aug 5, 2024

No description provided.

@snej snej force-pushed the lifetimebound branch 2 times, most recently from 433782e to a8a9a47 Compare August 5, 2024 19:46
@callumbirks
Copy link
Contributor

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.
@snej snej marked this pull request as ready for review August 28, 2024 19:19
@snej snej requested a review from callumbirks August 28, 2024 19:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants