core: optimize method Contains*