From 45c137d797a85c694897e8b1c5099abacc16e2f5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A5rten=20Nordheim?= Date: Tue, 30 Jan 2024 17:04:25 +0100 Subject: [PATCH] QHash: improve perf when detaching with potential growth 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 --- src/corelib/tools/qhash.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/corelib/tools/qhash.h b/src/corelib/tools/qhash.h index 72fdb70c542..216d710cc98 100644 --- a/src/corelib/tools/qhash.h +++ b/src/corelib/tools/qhash.h @@ -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)