No, that is the most efficient way to calculate it. The only alternative is caching the value, i.e. incrementing a var every time something is added to the list and decrementing it whenever something gets removed.


Always learn from history, to be sure you make the same mistakes again...