small optimizations in TextWindow