QTextBoundaryFinder: squash the bitfield member

This is in the way of adding an inline member-swap() (can't take
references to bit-fields), and therefore move-assignment.

We can always redistribute the bits in freeBuffer later, if needed:
there are (and, since 6.0, were) no inline users of this member.

This should even improve codegen, as the compiler doesn't have to deal
with bit-fields anymore. There's no need to pessimize the code for
that kind of flexibility until another user actually surfaces.

Amends the start of the public history.

Task-number: QTBUG-138659
Pick-to: 6.10 6.9 6.8 6.5
Change-Id: I47eb96da87bf4e3f1052e9f455943d9dea3121d1
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
This commit is contained in:
Marc Mutz 2025-09-11 13:08:05 +02:00
parent 901ccf7608
commit cc16e9e403
2 changed files with 1 additions and 7 deletions

View File

@ -104,7 +104,6 @@ static void init(QTextBoundaryFinder::BoundaryType type, QStringView str, QCharA
*/ */
QTextBoundaryFinder::QTextBoundaryFinder() QTextBoundaryFinder::QTextBoundaryFinder()
: freeBuffer(true) : freeBuffer(true)
, unused{0}
{ {
} }
@ -117,7 +116,6 @@ QTextBoundaryFinder::QTextBoundaryFinder(const QTextBoundaryFinder &other)
, sv(other.sv) , sv(other.sv)
, pos(other.pos) , pos(other.pos)
, freeBuffer(true) , freeBuffer(true)
, unused{0}
{ {
if (other.attributes) { if (other.attributes) {
Q_ASSERT(sv.size() > 0); Q_ASSERT(sv.size() > 0);
@ -165,7 +163,6 @@ QTextBoundaryFinder &QTextBoundaryFinder::operator=(const QTextBoundaryFinder &o
*/ */
QTextBoundaryFinder::~QTextBoundaryFinder() QTextBoundaryFinder::~QTextBoundaryFinder()
{ {
Q_UNUSED(unused);
if (freeBuffer) if (freeBuffer)
free(attributes); free(attributes);
} }
@ -178,7 +175,6 @@ QTextBoundaryFinder::QTextBoundaryFinder(BoundaryType type, const QString &strin
, s(string) , s(string)
, sv(s) , sv(s)
, freeBuffer(true) , freeBuffer(true)
, unused{0}
{ {
if (sv.size() > 0) { if (sv.size() > 0) {
attributes = (QCharAttributes *) malloc((sv.size() + 1) * sizeof(QCharAttributes)); attributes = (QCharAttributes *) malloc((sv.size() + 1) * sizeof(QCharAttributes));
@ -212,7 +208,6 @@ QTextBoundaryFinder::QTextBoundaryFinder(BoundaryType type, QStringView string,
: t(type) : t(type)
, sv(string) , sv(string)
, freeBuffer(true) , freeBuffer(true)
, unused{0}
{ {
if (!sv.isEmpty()) { if (!sv.isEmpty()) {
if (buffer && bufferSize / int(sizeof(QCharAttributes)) >= sv.size() + 1) { if (buffer && bufferSize / int(sizeof(QCharAttributes)) >= sv.size() + 1) {

View File

@ -65,8 +65,7 @@ private:
QString s; QString s;
QStringView sv; QStringView sv;
qsizetype pos = 0; qsizetype pos = 0;
uint freeBuffer : 1; uint freeBuffer; // this may be used to store another 31 bit of data in the future
uint unused : 31;
QCharAttributes *attributes = nullptr; QCharAttributes *attributes = nullptr;
}; };