Improve performance a little bit

avoid unneeded repeated call to _update_viewport_margins