Skip to content

[libc++][string] Fix unnecessary padding for basic_string's __short #135973

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 2 additions & 10 deletions libcxx/include/string
Original file line number Diff line number Diff line change
Expand Up @@ -715,14 +715,6 @@ struct __can_be_converted_to_string_view
struct __uninitialized_size_tag {};
struct __init_with_sentinel_tag {};

template <size_t _PaddingSize>
struct __padding {
char __padding_[_PaddingSize];
};

template <>
struct __padding<0> {};

template <class _CharT, class _Traits, class _Allocator>
class basic_string {
public:
Expand Down Expand Up @@ -827,9 +819,9 @@ private:

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;
value_type : 0;
};

// The __endian_factor is required because the field we use to store the size
Expand Down Expand Up @@ -879,7 +871,7 @@ private:
unsigned char __is_long_ : 1;
unsigned char __size_ : 7;
};
_LIBCPP_NO_UNIQUE_ADDRESS __padding<sizeof(value_type) - 1> __padding_;
value_type : 0;
value_type __data_[__min_cap];
};

Expand Down
Loading