HomeWildfire Games

Optimize the GUI event broadcast

Description

Optimize the GUI event broadcast

Patch By: nani
Differential Revision: D2638

Event Timeline

vladislavbelov added inline comments.
/ps/trunk/source/gui/CGUI.cpp
285

You shouldn't construct std::set if you don't need its functionality.

296

Same.

/ps/trunk/source/gui/CGUI.h
658

It might be use std::unordered_map or similar in future.

/ps/trunk/source/gui/ObjectBases/IGUIObject.cpp
338–342

This whole code can be replaced by:

m_pGUI[eventName].emplace(this);
361

it->second.empty().

362

You've already found eventName in m_pGUI.m_EventIGUIObjects, why search again?

/ps/trunk/source/gui/CGUI.cpp
298

Should the removed object get notifications? I suppose it's the dangerous place.

bb added inline comments.Nov 14 2020, 11:33 PM
/ps/trunk/source/gui/CGUI.cpp
285

Don't even want to, but not creating segfaults

298

Don't see a removed object

/ps/trunk/source/gui/ObjectBases/IGUIObject.cpp
338–342

that won't even compile

/ps/trunk/source/gui/CGUI.cpp
285

You don't need std::set for that.

/ps/trunk/source/gui/ObjectBases/IGUIObject.cpp
338–342

m_pGUI.m_EventIGUIObjects[eventName].emplace(this).

Stan added a subscriber: Stan.Nov 14 2020, 11:44 PM
Stan added inline comments.
/ps/trunk/source/gui/CGUI.cpp
285

std::unordered_set might wok better if we do need unicity, else vector

298

Ptr could be nullptr

/ps/trunk/source/gui/ObjectBases/IGUIObject.cpp
338–342

m_pGUI.m_EventIGUIObjects.emplace(this).

/ps/trunk/source/gui/CGUI.cpp
285

You don't need to find something here, so no needs to use some kind of maps.

298

I suppose it can't be nullptr.

I mean can someone unset handlers during that call? If yes - then the behaviour was changed afaics.

wraitii added inline comments.
/ps/trunk/source/gui/CGUI.cpp
298

I don't think anything prevents unsetting handlers at runtime, nor setting them, actually. I don't think it was particularly well defined before, but it's not now.

bb added inline comments.Nov 15 2020, 2:23 PM
/ps/trunk/source/gui/CGUI.cpp
298

In theory one could unset handlers. However there is only a difference if we are removing on objects which used to be processed later and aren't brothers. One should question though if the original behaviour is right: the event was originally send when the object was in the list, so one might expect the event to be received. This actually seems to make it rather more well-defined than less.

Stan added inline comments.Nov 15 2020, 5:13 PM
/ps/trunk/source/gui/CGUI.cpp
43

Missing
(Breaks without PCH)

#include <set>