From e40411cdc287343a32a8371f2116fcc11545b466 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Wed, 13 Feb 2013 22:58:01 +0300 Subject: Improve event.getId() speed. --- src/gui/widgets/setupitem.cpp | 14 ++++++++------ src/gui/widgets/sliderlist.cpp | 5 +++-- src/gui/widgets/tabbedarea.cpp | 6 +++--- 3 files changed, 14 insertions(+), 11 deletions(-) (limited to 'src/gui/widgets') diff --git a/src/gui/widgets/setupitem.cpp b/src/gui/widgets/setupitem.cpp index efa96136f..d9071aec4 100644 --- a/src/gui/widgets/setupitem.cpp +++ b/src/gui/widgets/setupitem.cpp @@ -324,17 +324,18 @@ void SetupItemTextField::action(const gcn::ActionEvent &event) if (!mTextField) return; - if (event.getId() == mWidget->getActionEventId()) + const std::string &eventId = event.getId(); + if (eventId == mWidget->getActionEventId()) { fromWidget(); } - else if (event.getId() == mEventName + "_EDIT") + else if (eventId == mEventName + "_EDIT") { mEditDialog = new EditDialog(mText, mTextField->getText(), mEventName + "_EDIT_OK"); mEditDialog->addActionListener(this); } - else if (event.getId() == mEventName + "_EDIT_OK") + else if (eventId == mEventName + "_EDIT_OK") { mTextField->setText(mEditDialog->getMsg()); mEditDialog = nullptr; @@ -449,17 +450,18 @@ void SetupItemIntTextField::action(const gcn::ActionEvent &event) if (!mTextField) return; - if (event.getId() == mWidget->getActionEventId()) + const std::string &eventId = event.getId(); + if (eventId == mWidget->getActionEventId()) { fromWidget(); } - else if (event.getId() == mEventName + "_EDIT") + else if (eventId == mEventName + "_EDIT") { mEditDialog = new EditDialog(mText, mTextField->getText(), mEventName + "_EDIT_OK"); mEditDialog->addActionListener(this); } - else if (event.getId() == mEventName + "_EDIT_OK") + else if (eventId == mEventName + "_EDIT_OK") { mTextField->setValue(atoi(mEditDialog->getMsg().c_str())); mEditDialog = nullptr; diff --git a/src/gui/widgets/sliderlist.cpp b/src/gui/widgets/sliderlist.cpp index 55cda4d26..70734b707 100644 --- a/src/gui/widgets/sliderlist.cpp +++ b/src/gui/widgets/sliderlist.cpp @@ -145,13 +145,14 @@ void SliderList::action(const gcn::ActionEvent &event) if (!mListModel) return; - if (event.getId() == mPrevEventId) + const std::string &eventId = event.getId(); + if (eventId == mPrevEventId) { mSelectedIndex --; if (mSelectedIndex < 0) mSelectedIndex = mListModel->getNumberOfElements() - 1; } - else if (event.getId() == mNextEventId) + else if (eventId == mNextEventId) { mSelectedIndex ++; if (mSelectedIndex >= mListModel->getNumberOfElements()) diff --git a/src/gui/widgets/tabbedarea.cpp b/src/gui/widgets/tabbedarea.cpp index b0999fbd4..82f7b82e4 100644 --- a/src/gui/widgets/tabbedarea.cpp +++ b/src/gui/widgets/tabbedarea.cpp @@ -524,18 +524,18 @@ void TabbedArea::action(const gcn::ActionEvent& actionEvent) } else { - if (actionEvent.getId() == "shift_left") + const std::string &eventId = actionEvent.getId(); + if (eventId == "shift_left") { if (mTabScrollIndex) --mTabScrollIndex; } - else if (actionEvent.getId() == "shift_right") + else if (eventId == "shift_right") { if (mTabScrollIndex < mTabs.size() - 1) ++mTabScrollIndex; } adjustTabPositions(); - updateArrowEnableState(); } } -- cgit v1.2.3-70-g09d2