forked from qt-creator/qt-creator
LayoutBuilder: Initialize BuilderItem::apply more directly
Also, add some timing information. Change-Id: I5d38cac9e7ad0afb24504ff521f31d5202268462 Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
This commit is contained in:
@@ -27,18 +27,16 @@ public:
|
||||
// Property setter
|
||||
template <typename Id, typename Arg>
|
||||
BuilderItem(IdAndArg<Id, Arg> && idarg)
|
||||
{
|
||||
apply = [&idarg](X *x) { doit(x, Id{}, idarg.arg); };
|
||||
}
|
||||
: apply([&idarg](X *x) { doit(x, Id{}, idarg.arg); })
|
||||
{}
|
||||
|
||||
// Nested child object
|
||||
template <typename Inner>
|
||||
BuilderItem(Inner && p)
|
||||
{
|
||||
apply = [&p](X *x) { doit(x, NestId{}, std::forward<Inner>(p)); };
|
||||
}
|
||||
: apply([&p](X *x) { doit(x, NestId{}, std::forward<Inner>(p)); })
|
||||
{}
|
||||
|
||||
std::function<void(X *)> apply;
|
||||
const std::function<void(X *)> apply;
|
||||
};
|
||||
|
||||
#define QTC_DEFINE_BUILDER_SETTER(name, setter) \
|
||||
|
37
tests/manual/layoutbuilder/v2/README.md
Normal file
37
tests/manual/layoutbuilder/v2/README.md
Normal file
@@ -0,0 +1,37 @@
|
||||
|
||||
This is an ad-hoc instruction count to judge the overhead imposed
|
||||
by Layoutbuilder for
|
||||
|
||||
Label ll {
|
||||
text("World")
|
||||
};
|
||||
|
||||
|
||||
(1) up to Label::Label
|
||||
(2) after new Label to up to doit()
|
||||
(3) tuple stuff in doit up to QLabel::setText parameter construction
|
||||
|
||||
|
||||
With
|
||||
|
||||
BuilderItem(IdAndArg<Id, Arg> && idarg)
|
||||
{
|
||||
apply = [&idarg](X *x) { doit(x, Id{}, idarg.arg); };
|
||||
}
|
||||
|
||||
|
||||
(1) (2) + (3) Sum
|
||||
-O0 547 259 + 802 1608
|
||||
-O2 24 23 47
|
||||
|
||||
|
||||
|
||||
With
|
||||
|
||||
BuilderItem(IdAndArg<Id, Arg> && idarg)
|
||||
: apply([&idarg](X *x) { doit(x, Id{}, idarg.arg); })
|
||||
{}
|
||||
|
||||
|
||||
(1) (2) + (3) Sum
|
||||
-O2 5 23 28
|
@@ -61,16 +61,14 @@ public:
|
||||
// Property setter
|
||||
template <typename Id, typename Arg>
|
||||
BuilderItem(IdAndArg<Id, Arg> && idarg)
|
||||
{
|
||||
apply = [&idarg](X *x) { doit(x, Id{}, idarg.arg); };
|
||||
}
|
||||
: apply([&idarg](X *x) { doit(x, Id{}, idarg.arg); })
|
||||
{}
|
||||
|
||||
// Nested child object
|
||||
template <typename Inner>
|
||||
BuilderItem(Inner && p)
|
||||
{
|
||||
apply = [&p](X *x) { doit(x, NestId{}, std::forward<Inner>(p)); };
|
||||
}
|
||||
: apply([&p](X *x) { doit(x, NestId{}, std::forward<Inner>(p)); })
|
||||
{}
|
||||
|
||||
std::function<void(X *)> apply;
|
||||
};
|
||||
|
Reference in New Issue
Block a user