LayoutBuilder: Potentially save a few cycles

... by not actually creating the unused instances of the Id types.

Change-Id: I6955046fa1b457ea70d36090d3bf0051b31dfdaa
Reviewed-by: Marcus Tillmanns <marcus.tillmanns@qt.io>
This commit is contained in:
hjk
2024-06-04 11:13:36 +02:00
parent 6db18c34c4
commit 1c9242bab2

View File

@@ -43,13 +43,12 @@ namespace Layouting {
class NestId {};
template <typename T1, typename T2>
template <typename Id, typename Arg>
class IdAndArg
{
public:
IdAndArg(const T1 &id, const T2 &arg) : id(id), arg(arg) {}
const T1 id;
const T2 arg; // FIXME: Could be const &, but this would currently break bindTo().
IdAndArg(Id, const Arg &arg) : arg(arg) {}
const Arg arg; // FIXME: Could be const &, but this would currently break bindTo().
};
// The main dispatcher
@@ -70,7 +69,7 @@ public:
template <typename Id, typename Arg>
BuilderItem(IdAndArg<Id, Arg> && idarg)
{
apply = [&idarg](X *x) { doit(x, idarg.id, idarg.arg); };
apply = [&idarg](X *x) { doit(x, Id{}, idarg.arg); };
}
std::function<void(X *)> apply;