QDuplicateTracker: fix the static buffer size calculation
Instead of just sizeof(T), we, of course, also need to take the support structure into account, to wit: the bucket list and, in the node, the next pointer and the stored hash value. Change-Id: I8227a95c49e316aacf3d4efd8f6170ea3bea1cf0 Reviewed-by: Andrei Golubev <andrei.golubev@qt.io> Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> (cherry picked from commit 3c88e12beb22d8ea11b8a7006a71ba9773c6d183) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
parent
d95809470c
commit
41a397701c
@ -73,7 +73,13 @@ class QDuplicateTracker {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
char buffer[Prealloc * sizeof(T)];
|
struct node_guesstimate { void *next; size_t hash; T value; };
|
||||||
|
static constexpr size_t bufferSize(size_t N) {
|
||||||
|
return N * sizeof(void*) // bucket list
|
||||||
|
+ N * sizeof(node_guesstimate); // nodes
|
||||||
|
}
|
||||||
|
|
||||||
|
char buffer[bufferSize(Prealloc)];
|
||||||
std::pmr::monotonic_buffer_resource res{buffer, sizeof buffer};
|
std::pmr::monotonic_buffer_resource res{buffer, sizeof buffer};
|
||||||
std::pmr::unordered_set<T, QHasher<T>> set{&res};
|
std::pmr::unordered_set<T, QHasher<T>> set{&res};
|
||||||
#else
|
#else
|
||||||
|
Loading…
x
Reference in New Issue
Block a user