If you are checking repeatedly for existence of an object in an array you should maybe look into
- Keeping the array sorted at all times by doing insertion sort in your array (put new objects in on the right place)
- Make updating objects as remove+sorted insert operation and
- Use a binary search lookup in your
contains(a, obj).