Introduce counter-shares-index to reduce CPU/memory usage
@cazfi:
It looks it works at least. But patch contains bad whitespaces. I send to allow test it by greater group of people.
Sorry I do not tested it properly. I eliminate one evident bug in my code. Code is complicated now, so I do not known if applying this patch is necessary for a while. I tested it more by now and it seems to work, but again, code is not clear, so I do not known if there is no more bugs. Somebody else must test it and read, but for that PR exist.
Currently, server will process each counter of the same type, but that do not make sense for some kind of counter (owned, celebrating, disorder).
This change seems to skip currently processed counter by sharing index. It also modify iterators to check index is smaller than excepted and do not process counter if so. If index is excepted, then we increase excepted value of index and process counter. By this little modifications, each kind of counters will be processed only once. To avoid this, simply change function returns if each counter of this type should share index.