Avoid duplicate implementations of existing checks

The array_flip change is a bit different because there is no
existing check. The reason is that the array is usually very small
and array_flip is more expensive and confusing than a simple search.

Change-Id: Ibed9242e44db21db6c14c42de23f3bf68eddd315
Merge "Avoid duplicate implementations of existing checks"