add some speedup on slg

Signed-off-by: xiehuc <xiehuc@gmail.com>
add a unit test

Signed-off-by: xiehuc <xiehuc@gmail.com>
fix bugs

Signed-off-by: xiehuc <xiehuc@gmail.com>