Unlike Arena::CreateMessage, Arena::Create creates only the top level object
from arena even if it is arena constructalble; e.g. messages, RepeatedPtrField,
etc. This renders arenas less effective.
Instead of asking users to be aware of such nuances to use the right API for
the right type, this CL makes Arena::Create recognizes and fully supports arena
constructable types.
While extremly rare, some users try to emulate Arena::CreateMessage with
Arena::Create by passing arena parameter twice. For example,
```
auto foo = Arena::Create<Foo>(&arena, &arena); // bad
```
This pattern is not supported and will break after this change. The following
is recommended instead.
```
auto foo = Arena::CreateMessage<Foo>(&arena); // recommended
auto foo = Arena::Create<Foo>(&arena); // after this change
```
PiperOrigin-RevId: 585709990
- Avoid redundant calls to `GetArena()`.
- Only do a single call to `xxx_clear()` if needed.
- Set the oneof_case once, if needed.
- Use CopyConstruct for new objects, like we do for non-oneof Merge.
- Avoid the _Internal::mutable_xxx functions, as they are not needed anymore.
PiperOrigin-RevId: 585705944
This change names the lifetime of Mut<'a, T> and requires that T outlives 'a. The motivation for this change came up while implementing `Map<K, ProtoStr>`. The Map implementation makes it so that `V` needs to implement the `MapWithKeyOps` trait which has an associated type with a lifetime (`Value<'a>`. The lifetime bound on `T` ensures that e.g. for `MapWithKeyOps<Value<'b>=&'b ProtoStr>` `'a` outlives `'b`.
PiperOrigin-RevId: 585657154
There is no canonical rules_ruby repo today, and we don't want our fork to become one. In order to unblock inclusion of Protobuf in the bzlmod registry, we're making this a dev dependency and dropping support for Bazel/Ruby.
Fixes#14569
PiperOrigin-RevId: 584393841
- Inline the once_flag object. This avoids an unnecessary indirection and secondary object.
- Reorganize the fields to reduce the size by 8 bytes.
PiperOrigin-RevId: 584322655
This change implements the Proxied trait for the Map type.
It leaves a TODO to implement SettableValue. I haven't implemented SettableValue yet because I have not yet been able to verify that we get the right copy_from semantics for both kernels. I'll implement set_on in a follow up.
PiperOrigin-RevId: 584285061
EXPECT_DEBUG_DEATH runs the statement without expecting a death in NDEBUG mode, causing a test failure in asan due to reaching `__builtin_unreachable`.
Also, improve a bit the definition of Unreachable to be more readable/useful.
PiperOrigin-RevId: 584133307
This allows for better code generation in C++20 for algorithms that take advantage of random access vs contiguous data.
```
name old INSTRUCTIONS/op new INSTRUCTIONS/op delta
BM_RepeatedField_Sort 5.74k ± 0% 5.74k ± 0% -0.13% (p=0.000 n=179+183)
BM_RepeatedField_ToVector 693 ± 0% 693 ± 0% ~ (p=0.153 n=93+91)
BM_RepeatedPtrField_SortIndirect 562 ± 0% 559 ± 0% -0.53% (p=0.000 n=92+92)
```
PiperOrigin-RevId: 583983215