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 {}; class NestId {};
template <typename T1, typename T2> template <typename Id, typename Arg>
class IdAndArg class IdAndArg
{ {
public: public:
IdAndArg(const T1 &id, const T2 &arg) : id(id), arg(arg) {} IdAndArg(Id, const Arg &arg) : arg(arg) {}
const T1 id; const Arg arg; // FIXME: Could be const &, but this would currently break bindTo().
const T2 arg; // FIXME: Could be const &, but this would currently break bindTo().
}; };
// The main dispatcher // The main dispatcher
@@ -70,7 +69,7 @@ public:
template <typename Id, typename Arg> template <typename Id, typename Arg>
BuilderItem(IdAndArg<Id, Arg> && idarg) 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; std::function<void(X *)> apply;