* src/buffer.h (struct buffer): New field 'long_line_optimizations_p'.
* src/buffer.c (syms_of_buffer): New variable 'long-line-threshold'.
(reset_buffer): Initialize the 'long_line_optimizations_p' field.
(Fbuffer_swap_text): Handle it.
* src/xdisp.c (redisplay_window): Set 'long_line_optimizations_p' when
a buffer contains long lines.
(init_iterator): Use 'long_line_optimizations_p'.
(get_narrowed_begv): Update.
(SET_WITH_NARROWED_BEGV): New macro.
(unwind_narrowed_begv): New internal function used by the new macro.
(back_to_previous_line_start, get_visually_first_element,
move_it_vertically_backward): Use the new macro.
* src/search.c (find_newline1): Make it externally visible.
* src/lisp.h: Make 'find_newline1' externally visible.
* src/dispextern.h (struct it): Update comment. Remove the
'WITH_NARROWED_BEGV' macro.
* etc/NEWS: Mention the 'long-line-threshold' variable.