Add performance optimization for  `empty` method