terminalwriter: optimize get_line_width() a bit
terminalwriter: optimize get_line_width() a bit

This function is called a lot when printing a lot of text, and is very
slow -- this speeds it up a bit.

pytest-dev/pytest,The-Compiler/pytest,RonnyPfannschmidt/pytest,The-Compiler/pytest,markshao/pytest,nicoddemus/pytest,Akasurde/pytest,nicoddemus/pytest