From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.devel Subject: Re: State of the overlay tree branch? Date: Mon, 19 Mar 2018 08:50:46 +0200 Message-ID: <83tvtco8xl.fsf@gnu.org> References: > <834lldp18f.fsf@gnu.org>> Reply-To: Eli Zaretskii NNTP-Posting-Host: blaine.gmane.org X-Trace: blaine.gmane.org 1521442134 5541 195.159.176.226 (19 Mar 2018 06:48:54 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Mon, 19 Mar 2018 06:48:54 +0000 (UTC) Cc: emacs-devel@gnu.org To: Stefan Monnier Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Mon Mar 19 07:48:49 2018 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1exobB-0001Jp-Gk for ged-emacs-devel@m.gmane.org; Mon, 19 Mar 2018 07:48:49 +0100 Original-Received: from localhost ([::1]:40517 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1exodC-0005KW-PN for ged-emacs-devel@m.gmane.org; Mon, 19 Mar 2018 02:50:54 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:56673) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1exod0-0005G8-Ms for emacs-devel@gnu.org; Mon, 19 Mar 2018 02:50:43 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1exocw-0004a6-Mf for emacs-devel@gnu.org; Mon, 19 Mar 2018 02:50:42 -0400 Original-Received: from fencepost.gnu.org ([2001:4830:134:3::e]:49881) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1exocw-0004a2-I9; Mon, 19 Mar 2018 02:50:38 -0400 Original-Received: from [176.228.60.248] (port=1955 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1exocv-0002O2-SF; Mon, 19 Mar 2018 02:50:38 -0400 In-reply-to: (message from Stefan Monnier on Sun, 18 Mar 2018 21:33:05 -0400) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2001:4830:134:3::e X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.org gmane.emacs.devel:223806 Archived-At: > From: Stefan Monnier > Date: Sun, 18 Mar 2018 21:33:05 -0400 > > >> If lsp-mode/lsp-ui needs a fast line counter, one can easily be > >> provided by exposing find_newline to Lisp. IME, it's lightning-fast, > >> and should run circles around count-lines (used by line-number-at-pos). > > Having a fast line counter in Elisp would be terrific. > > It should be pretty easy to provide such a thing by relying on a cache > of the last call. This is already coded, see display_count_lines. That's what the native line-number display uses. Exposing it to Lisp should be easy. But I don't believe it could be orders of magnitude faster than count-lines, even though it doesn't need to convert character position to byte position. I'm guessing something entirely different and unrelated to line-counting per se is at work here. > Tho Sebastian's experience seems to indicate that the > current code doesn't only suffer from the time to count LF but also from > the time to process the markers. Not sure what marker processing did you have in mind. Can you elaborate? > I seem to remember someone else experiencing a similar problem and > suggesting that the problem lies in the charpos_to_bytepos (and/or > bytepos_to_charpos) conversion function, which iterates through all the > markers to try and find a "nearby" marker (because markers keep track > of both their bytepos and their charpos). Looking for a nearby marker > to avoid scanning the whole buffer is a good idea in many cases, but not > if scanning the list of markers takes more time than scanning the > whole buffer. But find_newline doesn't look for markers, and it converts character to byte position just 2 times. Or am I missing something?