[KProtocolInfoFactory] Don't clear cache if it had just been built

Authored by hein on Wed, Mar 7, 7:58 AM.



KProtocolInfoFactory::findProtocol clears its cache when requested an unknown protocol in the hope of finding it due to an outdated cache. However, when the cache had just been created, there's no point in clearing and recreating it right away

Test Plan

Mitigates the effects of D9094 somewhat (takes 4.5ms instead of 9ms on startup for me now)

Diff Detail

R241 KIO
Automatic diff as part of commit; lint not applicable.
Automatic diff as part of commit; unit tests not applicable.
broulik created this revision.Wed, Mar 7, 7:58 AM
Restricted Application added a project: Frameworks. · View Herald TranscriptWed, Mar 7, 7:58 AM
broulik requested review of this revision.Wed, Mar 7, 7:58 AM
hein added a comment.Wed, Mar 7, 10:26 AM

Good idea, but every time one of those state tracking bools get copied my mind screams "BAD PATTERN". It's not the fault of your patch but I don't like how this cache handling is written - it'd be cleaner if fillCache had a return value for "I actually did work" and if the meaning of m_allProtocolsLoaded got inverted to being a dirty bit, so fillCache() itself can take care of the cache eviction code (qDeleteAll etc.) if dirty is set. Doing this instead creates a "now every time you want to change things you have to read site first and copy some boiler plate" situation.

hein commandeered this revision.Wed, Mar 7, 11:13 AM
hein edited reviewers, added: broulik; removed: hein.

Commandeering as agreed upon with Kai, new rev in a moment.

hein updated this revision to Diff 28916.Wed, Mar 7, 11:15 AM

Slightly cleaner approach.

hein added a reviewer: dfaure.Sat, Mar 10, 2:44 PM
dfaure accepted this revision.Sat, Mar 10, 7:33 PM
This revision is now accepted and ready to land.Sat, Mar 10, 7:33 PM
This revision was automatically updated to reflect the committed changes.