Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Change isset field from bool to uint8_t
Summary: We want to replace `isset` from `bool` to `bit` and we will do it step by step. So in this diff, we will replace `isset` from `bool` to `uint_8` and update related code. - It will replace: ``` struct Foo { private: struct __isset { bool field1; bool field2; // ... bool field9; bool __fbthrift_get (folly::index_constant<0>) const { return field1 ; } bool __fbthrift_get (folly::index_constant<1>) const { return field1; } ... bool __fbthrift_get (folly::index_constant<8>) const { return field9; } void __fbthrift_set (folly::index_constant<0>, bool isset_flag) const { field1 = isset_flag; return; } void __fbthrift_set (folly::index_constant<1>, bool isset_flag) const { field2 = isset_flag; return; } ... void __fbthrift_set (folly::index_constant<8>, bool isset_flag) const { field9 = isset_flag; return; } } __isset = {}; // ... }; ``` with: ``` struct Foo { private: struct __isset { uint_8 field1; uint_8 field2; // ... uint_8 field9; bool __fbthrift_get (folly::index_constant<0>) const { return field1 == 1; } bool __fbthrift_get (folly::index_constant<1>) const { return field1 == 1; } ... bool __fbthrift_get (folly::index_constant<8>) const { return field9 == 1; } void __fbthrift_set (folly::index_constant<0>, bool isset_flag) const { field1 = isset_flag ? 1 : 0;; } void __fbthrift_set (folly::index_constant<1>, bool isset_flag) const { field2 = isset_flag ? 1 : 0;; } ... void __fbthrift_set (folly::index_constant<8>, bool isset_flag) const { field9 = isset_flag ? 1 : 0;; } } __isset = {}; // ... }; ``` - Add new functions `make_optional_field_ref` and `make_field_ref` in detail namespace, and replace `optional_field_ref` and `field_ref` with these new functions. Next steps: - Change multiple isset fields into a single array of uint8_t - Compress array of uint8_t into bits. - Change isset struct into bitset. Reviewed By: Mizuchi Differential Revision: D30523019 fbshipit-source-id: 8d1060f89af560c9a5e707cba88dea0c2903d0f7
- Loading branch information