aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArmin Berres <armin.berres@basyskom.de>2010-06-24 16:43:01 +0200
committerSergiy Dubovik <sergiy.dubovik@nokia.com>2010-09-28 13:34:38 +0300
commite7a77ac46a1de1a770719aa9d58c244024311dfa (patch)
tree9dbd2b55701710dd08b57127e491ee2c1f31cc0c
parent2d436c180c2d0b0b93bc9f3c69498f840f0b062e (diff)
Changes: inline call to MStyleContainer::operator->()
RevBy: Peter Penz Details: operator->() called on all types of style containers is one of the most executed methods of every Meego Touch application. By inlining this call we can save quite some method calls. As inlining a method is a binary incompatible change a dummy method is introduced which forces gcc to also create a non-inlined version of the method. When we are allowed to do the next binary incompatible changes it should be removed. See also NB#174717.
-rw-r--r--mgen/mgen_processor.cpp6
-rw-r--r--src/corelib/style/mstyle.cpp6
-rw-r--r--src/corelib/style/mstyle.h14
3 files changed, 15 insertions, 11 deletions
diff --git a/mgen/mgen_processor.cpp b/mgen/mgen_processor.cpp
index 5fde33b6..a1be77a7 100644
--- a/mgen/mgen_processor.cpp
+++ b/mgen/mgen_processor.cpp
@@ -929,10 +929,10 @@ void generateStyleDataCpp(const StyleClass *c, const QList<QString>& modes, cons
cpp << " delete d_ptr;\n";
cpp << "}\n\n";
- // -> operator
- cpp << "const " << c->name() << "* " << c->name() << "Container::operator->() const\n";
+ // _dummyNeverToBeUsed
+ cpp << c->name() << "Container::dummyNeverToBeUsedPtr " << c->name() << "Container::_dummyNeverToBeUsed()\n";
cpp << "{\n";
- cpp << " return static_cast<const " << c->name() << "*>(currentStyle());\n";
+ cpp << " return &" << c->name() << "Container::operator->;\n";
cpp << "}\n\n";
// styleType
diff --git a/src/corelib/style/mstyle.cpp b/src/corelib/style/mstyle.cpp
index 22fe39bf..4d7b5495 100644
--- a/src/corelib/style/mstyle.cpp
+++ b/src/corelib/style/mstyle.cpp
@@ -234,12 +234,6 @@ QString MStyleContainer::currentMode() const
return d_ptr->currentMode;
}
-// returns pointer to the current style
-const MStyle *MStyleContainer::operator->() const
-{
- return currentStyle();
-}
-
// virtual method which returns the name of the style in this container instance
const char *MStyleContainer::styleType() const
{
diff --git a/src/corelib/style/mstyle.h b/src/corelib/style/mstyle.h
index 56e9223b..8bf65098 100644
--- a/src/corelib/style/mstyle.h
+++ b/src/corelib/style/mstyle.h
@@ -59,27 +59,37 @@
private:
// style container macro
+// TODO: remove the dummy method below once we are allowed to break
+// the ABI. it just exists to make sure the inlined operator->()
+// is also exported as symbol
#define M_STYLE_CONTAINER(STYLE_CLASS) \
public: \
STYLE_CLASS##Container(); \
virtual ~STYLE_CLASS##Container(); \
- const STYLE_CLASS* operator->() const; \
+ const STYLE_CLASS* operator->() const { return static_cast<const STYLE_CLASS*>(currentStyle()); } \
protected: \
STYLE_CLASS##Container(class STYLE_CLASS##ContainerPrivate* dd); \
virtual const char* styleType() const; \
class STYLE_CLASS##ContainerPrivate * const d_ptr; \
+ typedef const STYLE_CLASS* (STYLE_CLASS##Container::*dummyNeverToBeUsedPtr)() const; \
+ dummyNeverToBeUsedPtr _dummyNeverToBeUsed(); \
private: \
Q_DECLARE_PRIVATE(STYLE_CLASS##Container)
// style container macro for internal styles
+// TODO: remove the dummy method below once we are allowed to break
+// the ABI. it just exists to make sure the inlined operator->()
+// is also exported as symbo
#define M_STYLE_CONTAINER_INTERNAL(STYLE_CLASS) \
public: \
STYLE_CLASS##Container(); \
virtual ~STYLE_CLASS##Container(); \
- const STYLE_CLASS* operator->() const; \
+ const STYLE_CLASS* operator->() const { return static_cast<const STYLE_CLASS*>(currentStyle()); } \
protected: \
STYLE_CLASS##Container(class STYLE_CLASS##ContainerPrivate* dd); \
virtual const char* styleType() const; \
+ typedef const STYLE_CLASS* (STYLE_CLASS##Container::*dummyNeverToBeUsedPtr)() const; \
+ dummyNeverToBeUsedPtr _dummyNeverToBeUsed(); \
private: \
Q_DECLARE_PRIVATE(STYLE_CLASS##Container)