XEmacs at least has a cache mapping (line number -> newline location),
invalidated on significant buffer changes. Whether it's worthwhile in this
day and age I'm not sure: it may be faster to scan for nearby newlines
(probably both in the L2 cache if referenced recently) than to maintain
the line-start cache; and distant lines won't be in that cache anyway.