[Development] leak in QMetaObject?

André Somers andre at familiesomers.nl
Wed Jul 20 11:55:20 CEST 2016



Op 20/07/2016 om 11:39 schreef Edward Welbourne:
> Op 20/07/2016 om 10:41 schreef Olivier Goffart:
>>> The distribution does not matter. If it can be big, quadradic
>>> complexity can be a blocker.
> André Somers replied
>> Nonsense. There is no need to pessimize the frequent cases to cater
>> for avoiding a performance issue in an exceptional case.
> Well, it depends ...
>
> You've got some function, F, from number of connections to cost of any
> given way of handling connections.  You've got some distribution P over
> values n takes.  Your total cost is the sum of P(n).F(n) over that range
> of values.  The big-O discussion is usually about how F varies; but what
> actually matters is the sum of P(n).F(n). [...]
Yes, you are right of course.

But then again, it is easier to optimize the rare-but-expensive case in 
the application code than doing something about a frequent action that 
is slower than it could be. To stick to the concrete issue here: 
disconnecting a long list of connections using a loop is not very 
efficient if you do that one-by-one, Olivier pointed out you turn a O(N) 
into an O(N^2) if you then also do the clean-up. So you optize that to 
make sure that you can disconnect *all* connections for a given signal 
or slot instead, even if that means using an intermediary object or 
signal. If analysis shows that this case is slow, you spend a bit of 
time to optimize _that_ case. You cannot do the same for the many 
individual cases where there is maximum a handful of connections to any 
given signal or slot.

But: this reasoning is as much dependent on actual data on what the 
distribution of n is as the orignal statement that it does make sense. 
Hence my question on the availability of such data...

André




More information about the Development mailing list