+#if USE_SCROLL_HINTS
+ /*
+ * For pure efficiency, we'd want to transfer scrolling information
+ * from the window to newscr whenever the window is wide enough that
+ * its update will dominate the cost of the update for the horizontal
+ * band of newscr that it occupies. Unfortunately, this threshold
+ * tends to be complex to estimate, and in any case scrolling the
+ * whole band and rewriting the parts outside win's image would look
+ * really ugly. So. What we do is consider the window "wide" if it
+ * either (a) occupies the whole width of newscr, or (b) occupies
+ * all but at most one column on either vertical edge of the screen
+ * (this caters to fussy people who put boxes around full-screen
+ * windows). Note that changing this formula will not break any code,
+ * merely change the costs of various update cases.
+ */
+ wide = (begx <= 1 && win->_maxx >= (newscr->_maxx - 1));
+#endif
+
+ win->_flags &= ~_HASMOVED;
+
+ /*
+ * Microtweaking alert! This double loop is one of the genuine
+ * hot spots in the code. Even gcc doesn't seem to do enough
+ * common-subexpression chunking to make it really tense,
+ * so we'll force the issue.
+ */
+
+ /* limit(n) */
+ limit_x = win->_maxx;
+ /* limit(j) */
+ if (limit_x > newscr->_maxx - begx)
+ limit_x = newscr->_maxx - begx;
+
+ for (i = 0, m = begy + win->_yoffset;
+ i <= win->_maxy && m <= newscr->_maxy;
+ i++, m++) {
+ register struct ldat *nline = &newscr->_line[m];
+ register struct ldat *oline = &win->_line[i];
+
+ if (oline->firstchar != _NOCHANGE) {
+ int last = oline->lastchar;
+
+ if (last > limit_x)
+ last = limit_x;
+
+ for (j = oline->firstchar, n = j + begx; j <= last; j++, n++) {
+ if (!CharEq(oline->text[j], nline->text[n])) {
+ nline->text[n] = oline->text[j];
+ CHANGED_CELL(nline, n);