diff options
author | Andrei Karas <akaras@inbox.ru> | 2011-06-30 04:58:55 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2011-06-30 04:58:55 +0300 |
commit | a7c7cc655f94acc4476e681ac258ff6981702944 (patch) | |
tree | f7d504f11cafcd32e563f1f8a0954c522ba902b8 /src/guichan/widget.cpp | |
parent | dda225eebf1c3cb9e0b4e657a0875d1180380159 (diff) | |
download | mv-a7c7cc655f94acc4476e681ac258ff6981702944.tar.gz mv-a7c7cc655f94acc4476e681ac258ff6981702944.tar.bz2 mv-a7c7cc655f94acc4476e681ac258ff6981702944.tar.xz mv-a7c7cc655f94acc4476e681ac258ff6981702944.zip |
Small speed improve in guichan code.
Diffstat (limited to 'src/guichan/widget.cpp')
-rw-r--r-- | src/guichan/widget.cpp | 15 |
1 files changed, 5 insertions, 10 deletions
diff --git a/src/guichan/widget.cpp b/src/guichan/widget.cpp index e143e4a97..8ec3a8178 100644 --- a/src/guichan/widget.cpp +++ b/src/guichan/widget.cpp @@ -69,6 +69,7 @@ namespace gcn Font* Widget::mGlobalFont = NULL; DefaultFont Widget::mDefaultFont; std::list<Widget*> Widget::mWidgets; + std::set<Widget*> Widget::mWidgetsSet; Widget::Widget() : mForegroundColor(0x000000), @@ -87,6 +88,7 @@ namespace gcn mCurrentFont(NULL) { mWidgets.push_back(this); + mWidgetsSet.insert(this); } Widget::~Widget() @@ -104,6 +106,7 @@ namespace gcn _setFocusHandler(NULL); mWidgets.remove(this); + mWidgetsSet.erase(this); } void Widget::drawFrame(Graphics* graphics) @@ -482,16 +485,8 @@ namespace gcn bool Widget::widgetExists(const Widget* widget) { - bool result = false; - - std::list<Widget*>::iterator iter; - for (iter = mWidgets.begin(); iter != mWidgets.end(); ++iter) - { - if (*iter == widget) - return true; - } - - return result; + return mWidgetsSet.find(const_cast<Widget*>(widget)) + != mWidgetsSet.end(); } bool Widget::isTabInEnabled() const |