Netflix/RxJava — pull request #818 by akarnokd (2014-02-05 20:50:35+00:00)
Title: CompositeSubscription memory reduction

Since CompositeSubscription is now used everywhere with Subscriber, I looked at the code again and tried to reduce memory consumption. I've added CLEAR_STATE_UNSUBSCRIBED singleton to transition into when unsubscribed. Note that the previous version kept the subscription array after the unsubscription, keeping references to other subscriptions alive (although unsubscribed); I'm not certain why unsubscription didn't simply discard the array before.

I've played with changing the ```add``` and ```remove``` methods (not included in this PR) to do more direct array manipulation with about 10-40% speed increase for tests like add directly followed by remove. The speed increase comes from:
- using arraycopy to avoid dynamic array creation in copyOf,
- handling case where CS contains a single item to be removed and transitions into CLEAR_STATE instead of creating a new empty state.