Make height calculation more performant