Optimize functions for testing whether character is in bag.