mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-01-19 00:37:25 +01:00
[escher] Move View's destructor, and several other methods, to the header, so that the compiler can leverage its prior knowledge of the fact that the destructor is trivial (noticed by disassembling the code) to greatly optimize derived classes' destructors.
Signed-off-by: Lionel Debroux <lionel_debroux@yahoo.fr>
This commit is contained in:
committed by
EmilieNumworks
parent
1a8c6b6ae9
commit
ddebc06fa5
@@ -26,12 +26,21 @@ class View {
|
||||
friend class TransparentView;
|
||||
public:
|
||||
View();
|
||||
virtual ~View();
|
||||
virtual ~View() {
|
||||
for (int i = 0; i < numberOfSubviews(); i++) {
|
||||
View * subview = subviewAtIndex(i);
|
||||
if (subview != nullptr) {
|
||||
subview->m_superview = nullptr;
|
||||
}
|
||||
}
|
||||
}
|
||||
View(View&& other) = default;
|
||||
View(const View& other) = delete;
|
||||
View& operator=(const View& other) = delete;
|
||||
View& operator=(View&& other) = delete;
|
||||
void resetSuperview();
|
||||
void resetSuperview() {
|
||||
m_superview = nullptr;
|
||||
}
|
||||
/* The drawRect method should be implemented by each View subclass. In a
|
||||
* typical drawRect implementation, a subclass will make drawing calls to the
|
||||
* Kandinsky library using the provided context. */
|
||||
@@ -66,8 +75,12 @@ protected:
|
||||
#endif
|
||||
KDRect m_frame;
|
||||
private:
|
||||
virtual int numberOfSubviews() const;
|
||||
virtual View * subviewAtIndex(int index);
|
||||
virtual int numberOfSubviews() const {
|
||||
return 0;
|
||||
}
|
||||
virtual View * subviewAtIndex(int index) {
|
||||
return nullptr;
|
||||
}
|
||||
virtual void layoutSubviews();
|
||||
virtual const Window * window() const;
|
||||
KDRect redraw(KDRect rect, KDRect forceRedrawRect = KDRectZero);
|
||||
|
||||
@@ -10,19 +10,6 @@ View::View() :
|
||||
{
|
||||
}
|
||||
|
||||
View::~View() {
|
||||
for (int i = 0; i < numberOfSubviews(); i++) {
|
||||
View * subview = subviewAtIndex(i);
|
||||
if (subview != nullptr) {
|
||||
subview->m_superview = nullptr;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void View::resetSuperview() {
|
||||
m_superview = nullptr;
|
||||
}
|
||||
|
||||
void View::drawRect(KDContext * ctx, KDRect rect) const {
|
||||
// By default, a view doesn't do anything
|
||||
// It's transparent!
|
||||
@@ -121,7 +108,6 @@ void View::setSize(KDSize size) {
|
||||
setFrame(KDRect(m_frame.origin(), size));
|
||||
}
|
||||
|
||||
|
||||
void View::setFrame(KDRect frame) {
|
||||
if (frame == m_frame) {
|
||||
return;
|
||||
@@ -183,15 +169,6 @@ KDSize View::minimalSizeForOptimalDisplay() const {
|
||||
return KDSizeZero;
|
||||
}
|
||||
|
||||
int View::numberOfSubviews() const {
|
||||
return 0;
|
||||
}
|
||||
|
||||
View * View::subviewAtIndex(int index) {
|
||||
assert(false);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void View::layoutSubviews() {
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user