Skip to content

styleitem: Don't destroy and recreate the style on every instance creation

Arjen Hiemstra requested to merge work/ahiemstra/guistyleitem into master

Parsing config and creating a new style for every instance is an incredibly expensive operation that shouldn't be done every time an instance is created. Moreover, the current code makes little sense to me as it completely removes the reason for storing things in a static in the first place.

Instead, just initialise the static style once and use that static for consecutive instances. This reduces the time needed to create an instance of Button from over 7ms(!) to around 0.4ms. As an additional bonus, store the style instance in a shared_ptr so we don't need to memory manage it.

Merge request reports

Loading