The way we did it is the properly efficient way, but same thing
uses more cpu cycles to call the function once for every client. Torque is stuff, and efficiency is everything.
Kalphiter and blocki's are identical, but kalphiters looks better. Use his.
Ran test on 98853 brick group.
Calling getCount() every time:
266
250
265
265
265
Average: 262.2
Calling getCount() once:
249
234
234
234
250
Average: 240.2
So while you are right, it's a very slight difference of 22 ms on my computer. This also wasn't done dedicated, which most likely would've shown much smaller results with a smaller difference.
I was also calling .getObject(%x) every time in the loop.