Skip to content

Commit

Permalink
QHash: improve perf when detaching with potential growth
Browse files Browse the repository at this point in the history
By not assuming we will have resized.
reserve(size() + 1) will have suffered a bit from this, but
that is probably not very common.

Change-Id: I8750d430f532a72729ed06e67c0f315707a916d6
Reviewed-by: Lars Knoll <lars@knoll.priv.no>
  • Loading branch information
Morten242 committed Jan 31, 2024
1 parent 86e9297 commit 45c137d
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/corelib/tools/qhash.h
Original file line number Diff line number Diff line change
Expand Up @@ -584,7 +584,7 @@ struct Data
numBuckets = GrowthPolicy::bucketsForCapacity(qMax(size, reserved));
spans = allocateSpans(numBuckets).spans;
size_t otherNSpans = other.numBuckets >> SpanConstants::SpanShift;
reallocationHelper(other, otherNSpans, true);
reallocationHelper(other, otherNSpans, numBuckets != other.numBuckets);
}

static Data *detached(Data *d)
Expand Down

0 comments on commit 45c137d

Please sign in to comment.