This CL collapses (strings, bytes) into primitives for message.cc::GetterForViewOrMut.
Strings, bytes, and all primitives have been unified, properly parameterized based on RsType.
Returning $pb$::Mut<$RsType$> and $pb$::View<$RsType$> made this possible.
Note that the vtables for primitives take in an additional type arg, so we've added that.
In addition, strings / bytes (aka stringlikes) require a transform, so that'll be invoked on an as-needed basis.
PiperOrigin-RevId: 592328216
Without this it shows up as a spurious warning of dead code from never constructed enum cases (rustc can't 'see' that the value can come across from C++)
PiperOrigin-RevId: 592209619
The x86 microbenchmark speedups here are only representative for packed repeated primitive fields, as they benefit from some improved vectorization.
For normal cases like non-repeated fields, the util/coding microbenchmarks showed roughly 18% for arm and 2-3% for 32 bit x86, 10% for 64 bit x86 (including loop overhead)
PiperOrigin-RevId: 592061508
This allows to reduce binary bloat (all calls to Clear are now defined out of line) and eliminate redundant calls to clear (since we only call it when it is needed).
PiperOrigin-RevId: 590944438
Do more inlining in certain callers of ParseLoop to avoid the extra stack frame.
This reduces the overall cost of maintaining the stack frames in functions like FastMtS1.
PiperOrigin-RevId: 590943926
This won't have much effect over the edition zero migration, since enums in any proto2/proto3 file are either exclusively closed/open, respectively. However, it will prefer enum-level features if there's only a single enum
PiperOrigin-RevId: 590642827
We do not expect well-behaved code to ever rely on this check and well-behaved code should not being paying the price for it. We still need to keep it until b/290091828 is fixed but we can move it to slow out-of-line function.
```
name old cpu/op new cpu/op delta
BM_RepeatedPtrField_Ctor 75.3ns ± 4% 63.8ns ± 1% -15.27% (p=0.000 n=99+86)
```
PiperOrigin-RevId: 590139004
We augment the TYPE_STRING block inside message.cc:GetterForViewOrMut so that we properly return a Mut for strings when it comes to submessages.
PiperOrigin-RevId: 589944498
This will guarantee that the output of TextFormat is always valid UTF-8. Prior to this change, any invalid UTF-8 would escape into the TextFormat output if users enabled `SetUseUtf8StringEscaping(true)` or called `Utf8DebugString()`.
This change currently only affects users who explicitly set `SetUseUtf8StringEscaping(true)` or use `Utf8DebugString()`, but the hope is to flip the default so that this mode is enabled unless overridden.
PiperOrigin-RevId: 589844142
This significantly simplifies the internals of PrimitiveMut,
and removes the need to refactor BytesMut and ProtoStrMut
to have the same runtime branching.
PiperOrigin-RevId: 589292565
Include a comment in the generated header about there being helpers
in GPBWellKnowTypes.h
Generate some extra code for the WKTs that have categories to help
ensure the categories get linked so developers don't have to use
-ObjC in some cases.
PiperOrigin-RevId: 589179237
We avoid one instruction and the memory access.
Instead of generating:
```
leaq 0xb98201(%rip), %rax
movq %rax, -0x8(%rsp)
```
It now generated just:
```
leaq 0xb981c1(%rip), %rax
```
PiperOrigin-RevId: 589152440
They should ignore presence and always process key and value.
Remove codegen for methods in MapEntry and use the ones from Message.
Delete dead code in MapTypeHandler.
PiperOrigin-RevId: 588826780
This change implements maps with keys and values of type string e.g. Map<ProtoStr, i32> and Map<ProtoStr, ProtoStr>.
Implementing the Map type for ProtoStr has been different from scalar types because ProtoStr is an unsized type i.e. its size is not known at compile time. The existing Map implementation assumed sized types in many places. To make unsized types fit into the existing code architecture I have added an associated type 'Value' to the MapWith*KeyOps traits. The associated type needs to be sized and is the type returned by the Map::get(self, key) method e.g. for aProtoStr, the `type Value = &ProtoStr`.
PiperOrigin-RevId: 588783751