From 1776cd1a452982cdcd271f8ebf312c41d7f295b9 Mon Sep 17 00:00:00 2001 From: Gordon Huang Date: Fri, 20 Sep 2024 10:16:10 -0700 Subject: [PATCH] Serialize ARRAY attributes with thrif type using thrift compact serializer Summary: As described in https://docs.google.com/document/d/1mJPBYrpUkAy2AeRCvQwEK0tS3tehswMsfsAyo4CKI9k/edit, this diff does the following. IF there is a thrift structure and the IGNORE bit is not set, it will use the NEW thrift serialization flow. Otherwise, it will use the old JSON serialize flow. Reviewed By: rushidesai Differential Revision: D62657548 fbshipit-source-id: f3948705c22f9193d68c33f6c2b3200356b4a5ee --- hphp/runtime/ext/fb/VariantController.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/hphp/runtime/ext/fb/VariantController.h b/hphp/runtime/ext/fb/VariantController.h index 6ecd3a1d25f33..e394706e12eb9 100644 --- a/hphp/runtime/ext/fb/VariantController.h +++ b/hphp/runtime/ext/fb/VariantController.h @@ -248,6 +248,7 @@ struct VariantControllerImpl { map.setIntishCast(idx, k, std::move(v)); } static int64_t mapSize(const MapType& map) { return map.size(); } + static int64_t mapSize(const_variant_ref map) { return map.toArray().size(); } static ArrayIter mapIterator(const MapType& map) { return ArrayIter(map); } @@ -272,6 +273,9 @@ struct VariantControllerImpl { } static int64_t vectorSize(const VectorType& vec) { return vec.size(); + } + static int64_t vectorSize(const_variant_ref vec) { + return vec.toArray().size(); } static void vectorAppend(VectorType& vec, const VariantType& v) { if constexpr (HackArraysMode == VariantControllerHackArraysMode::OFF) {