Skip to content

Commit 2b08d19

Browse files
iahsmeta-codesync[bot]
authored andcommitted
Remove redundant adapted serialized-size optimization
Summary: Remove the arithmetic-adapter `serializedSizeFixed` specialization from `Adapt.h`. Fixed-width protocol sizing ignores the converted value, and optimized builds already eliminate a side-effect-free `toThrift` conversion when its result is unused. An opt-mode disassembly check used the production `UnixTimestampThriftAdapter<std::chrono::microseconds>`. Its live conversion compiled to 54 bytes including a multiply and shifts, while the `serializedSizeI64` fallback compiled to the same 11-byte constant-return sequence both with and without this specialization. Reviewed By: hchokshi Differential Revision: D116857994 fbshipit-source-id: 652f16879e9fe4757b5ead54cb306a79e68a8069
1 parent 76ebf2e commit 2b08d19

1 file changed

Lines changed: 0 additions & 59 deletions

File tree

  • third-party/thrift/src/thrift/lib/cpp2

third-party/thrift/src/thrift/lib/cpp2/Adapt.h

Lines changed: 0 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -545,65 +545,6 @@ struct adapter_serialized_size<
545545
}
546546
};
547547

548-
template <typename Protocol>
549-
uint32_t serializedSizeFixed(Protocol& protocol, bool /*unused*/) {
550-
return protocol.serializedSizeBool();
551-
}
552-
template <typename Protocol>
553-
uint32_t serializedSizeFixed(Protocol& protocol, int8_t /*unused*/) {
554-
return protocol.serializedSizeByte();
555-
}
556-
template <typename Protocol>
557-
uint32_t serializedSizeFixed(Protocol& protocol, int16_t /*unused*/) {
558-
return protocol.serializedSizeI16();
559-
}
560-
template <typename Protocol>
561-
uint32_t serializedSizeFixed(Protocol& protocol, int32_t /*unused*/) {
562-
return protocol.serializedSizeI32();
563-
}
564-
template <typename Protocol>
565-
uint32_t serializedSizeFixed(Protocol& protocol, int64_t /*unused*/) {
566-
return protocol.serializedSizeI64();
567-
}
568-
template <typename Protocol>
569-
uint32_t serializedSizeFixed(Protocol& protocol, double /*unused*/) {
570-
return protocol.serializedSizeDouble();
571-
}
572-
template <typename Protocol>
573-
uint32_t serializedSizeFixed(Protocol& protocol, float /*unused*/) {
574-
return protocol.serializedSizeFloat();
575-
}
576-
577-
template <
578-
bool ZeroCopy,
579-
typename Tag,
580-
typename Adapter,
581-
typename AdaptedT,
582-
typename Protocol,
583-
typename FallbackF>
584-
struct adapter_serialized_size<
585-
ZeroCopy,
586-
Tag,
587-
Adapter,
588-
AdaptedT,
589-
Protocol,
590-
FallbackF,
591-
std::enable_if_t<
592-
!folly::is_detected_v<
593-
serialized_size_type,
594-
Tag,
595-
Adapter,
596-
AdaptedT,
597-
Protocol> &&
598-
std::is_arithmetic_v<decltype(Adapter::toThrift(
599-
std::declval<AdaptedT&>()))>>> {
600-
uint32_t operator()(
601-
Protocol& prot, const AdaptedT& /*unused*/, FallbackF /*unused*/) {
602-
return serializedSizeFixed(
603-
prot, decltype(Adapter::toThrift(std::declval<AdaptedT&>()))(0));
604-
}
605-
};
606-
607548
template <
608549
bool ZeroCopy,
609550
typename Tag,

0 commit comments

Comments
 (0)