Skip to content

Commit

Permalink
Reduce the diff
Browse files Browse the repository at this point in the history
  • Loading branch information
ldionne committed Sep 9, 2024
1 parent efc9123 commit 1151a32
Showing 1 changed file with 10 additions and 11 deletions.
21 changes: 10 additions & 11 deletions libcxx/include/string
Original file line number Diff line number Diff line change
Expand Up @@ -859,6 +859,13 @@ private:

enum { __min_cap = (sizeof(__long) - 1) / sizeof(value_type) > 2 ? (sizeof(__long) - 1) / sizeof(value_type) : 2 };

struct __short {
value_type __data_[__min_cap];
_LIBCPP_NO_UNIQUE_ADDRESS __padding<sizeof(value_type) - 1> __padding_;
unsigned char __size_ : 7;
unsigned char __is_long_ : 1;
};

// The __endian_factor is required because the field we use to store the size
// has one fewer bit than it would if it were not a bitfield.
//
Expand Down Expand Up @@ -901,16 +908,6 @@ private:

enum { __min_cap = (sizeof(__long) - 1) / sizeof(value_type) > 2 ? (sizeof(__long) - 1) / sizeof(value_type) : 2 };

#endif // _LIBCPP_ABI_ALTERNATE_STRING_LAYOUT

#ifdef _LIBCPP_ABI_ALTERNATE_STRING_LAYOUT
struct __short {
value_type __data_[__min_cap];
_LIBCPP_NO_UNIQUE_ADDRESS __padding<sizeof(value_type) - 1> __padding_;
unsigned char __size_ : 7;
unsigned char __is_long_ : 1;
};
#else
struct __short {
struct _LIBCPP_PACKED {
unsigned char __is_long_ : 1;
Expand All @@ -919,7 +916,9 @@ private:
_LIBCPP_NO_UNIQUE_ADDRESS __padding<sizeof(value_type) - 1> __padding_;
value_type __data_[__min_cap];
};
#endif

#endif // _LIBCPP_ABI_ALTERNATE_STRING_LAYOUT

static_assert(sizeof(__short) == (sizeof(value_type) * (__min_cap + 1)), "__short has an unexpected size.");

union __rep {
Expand Down

0 comments on commit 1151a32

Please sign in to comment.