misc optimizations for some class compare funtion

Signed-off-by: Xinze Chi <xmdxcxz@gmail.com>