small optimizations in span-math and get-span-width functions