From unknown Tue Jun 17 22:28:10 2025 X-Loop: help-debbugs@gnu.org Subject: bug#22763: 25.1.50; Feature Request -- A faster method to obtain line number at position. Resent-From: Keith David Bershatsky Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 22 Feb 2016 02:44:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 22763 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: 22763@debbugs.gnu.org X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Received: via spool by submit@debbugs.gnu.org id=B.145610898820024 (code B ref -1); Mon, 22 Feb 2016 02:44:01 +0000 Received: (at submit) by debbugs.gnu.org; 22 Feb 2016 02:43:08 +0000 Received: from localhost ([127.0.0.1]:36729 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84) (envelope-from ) id 1aXgSq-0005Cu-9i for submit@debbugs.gnu.org; Sun, 21 Feb 2016 21:43:08 -0500 Received: from eggs.gnu.org ([208.118.235.92]:40996) by debbugs.gnu.org with esmtp (Exim 4.84) (envelope-from ) id 1aXgSo-0005CZ-Lu for submit@debbugs.gnu.org; Sun, 21 Feb 2016 21:43:07 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aXgSi-0007h1-9L for submit@debbugs.gnu.org; Sun, 21 Feb 2016 21:43:01 -0500 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=0.8 required=5.0 tests=BAYES_50,T_DKIM_INVALID autolearn=disabled version=3.3.2 Received: from lists.gnu.org ([2001:4830:134:3::11]:51856) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aXgSi-0007gw-61 for submit@debbugs.gnu.org; Sun, 21 Feb 2016 21:43:00 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60198) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aXgSg-0004LS-K1 for bug-gnu-emacs@gnu.org; Sun, 21 Feb 2016 21:43:00 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aXgSd-0007ge-CH for bug-gnu-emacs@gnu.org; Sun, 21 Feb 2016 21:42:58 -0500 Received: from cobb.liquidweb.com ([50.28.13.150]:44488) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aXgSd-0007ga-3Y for bug-gnu-emacs@gnu.org; Sun, 21 Feb 2016 21:42:55 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lawlist.com; s=default; h=Content-Type:MIME-Version:Subject:To:From:Message-ID:Date; bh=5lI0zwL3CR/uVTT4TfqHPsDW2tdrw7DrslV0r9N/Sog=; b=7owZ5omdiLX5dUAg4b+FbbzJy1h1OTR7nb+EVcMJwnEDl0Uqx7Bnv5xyTtQqa+xIrKS8WgGF0MEL3+ahctqL2RTFzdt/uSaf1rTXkwQi2VSQhRcUGjCCctkXhqFAWmB+; Received: from cpe-45-48-239-195.socal.res.rr.com ([45.48.239.195]:53357 helo=server.private.localhost) by cobb.liquidweb.com with esmtp (Exim 4.82) (envelope-from ) id 1aXgSZ-0003Rc-Gg for bug-gnu-emacs@gnu.org; Sun, 21 Feb 2016 21:42:51 -0500 Date: Sun, 21 Feb 2016 18:42:52 -0800 Message-ID: From: Keith David Bershatsky MIME-Version: 1.0 (generated by - "") Content-Type: text/plain; charset=US-ASCII X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - cobb.liquidweb.com X-AntiAbuse: Original Domain - gnu.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - lawlist.com X-Get-Message-Sender-Via: cobb.liquidweb.com: acl_c_relayhosts_text_entry: lawlist|lawlist.com X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Received-From: 2001:4830:134:3::11 X-Spam-Score: -5.0 (-----) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -5.0 (-----) A while back, I posed a question on emacs.stackexchange.com for a faster method to obtain `line-number-at-pos`. A user by the name of Constantine came up with `(format-mode-line "%l")`, which is indeed much faster. I think the draft code below may be just a tad faster, with the added feature of the POS argument. http://emacs.stackexchange.com/questions/3821/a-faster-method-to-obtain-line-number-at-pos-in-large-buffers A user named wasamasa posted a comment: "Be aware that this method will give you "??" for lines exceeding line-number-display-limit-width which is set to a value of 200 per default as I found out here." And Stefan posted a comment: "IIRC the result may also be unreliable if there have been modifications in the buffer since the last redisplay." The thread has received 555 hits in the past year, and several have star-ed it and up-voted the question and answer. The following is a draft in C based on the existing function `decode_mode_spec` that lets the user input the POS as an argument without the necessity to use `goto-char`. I'm not sure if it resolves either of the comments above. The draft is not meant to be a patch per se, because I'm not a programmer and am just beginning my tinkering quest into the language of C. I have been using it in my own setup for about a week and I haven't seen any ill effects. It can of course use some TLC by someone more knowledgeable than myself. static const char * internal_line_number_at_position (struct window *w, register int c, int field_width, Lisp_Object *string) { Lisp_Object obj; struct frame *f = XFRAME (WINDOW_FRAME (w)); char *decode_mode_spec_buf = f->decode_mode_spec_buffer; /* We are going to use f->decode_mode_spec_buffer as the buffer to produce strings from numerical values, so limit preposterously large values of FIELD_WIDTH to avoid overrunning the buffer's end. The size of the buffer is enough for FRAME_MESSAGE_BUF_SIZE bytes plus the terminating null. */ int width = min (field_width, FRAME_MESSAGE_BUF_SIZE (f)); struct buffer *b = current_buffer; obj = Qnil; *string = Qnil; switch (c) { case 'l': { ptrdiff_t startpos, startpos_byte, line, linepos, linepos_byte; ptrdiff_t topline, nlines, height; ptrdiff_t junk; /* %c and %l are ignored in `frame-title-format'. */ if (mode_line_target == MODE_LINE_TITLE) return ""; startpos = marker_position (w->start); startpos_byte = marker_byte_position (w->start); height = WINDOW_TOTAL_LINES (w); /* If we decided that this buffer isn't suitable for line numbers, don't forget that too fast. */ if (w->base_line_pos == -1) goto no_value; /* If the buffer is very big, don't waste time. */ if (INTEGERP (Vline_number_display_limit) && BUF_ZV (b) - BUF_BEGV (b) > XINT (Vline_number_display_limit)) { w->base_line_pos = 0; w->base_line_number = 0; goto no_value; } if (w->base_line_number > 0 && w->base_line_pos > 0 && w->base_line_pos <= startpos) { line = w->base_line_number; linepos = w->base_line_pos; linepos_byte = buf_charpos_to_bytepos (b, linepos); } else { line = 1; linepos = BUF_BEGV (b); linepos_byte = BUF_BEGV_BYTE (b); } /* Count lines from base line to window start position. */ nlines = display_count_lines (linepos_byte, startpos_byte, startpos, &junk); topline = nlines + line; /* Determine a new base line, if the old one is too close or too far away, or if we did not have one. "Too close" means it's plausible a scroll-down would go back past it. */ if (startpos == BUF_BEGV (b)) { w->base_line_number = topline; w->base_line_pos = BUF_BEGV (b); } else if (nlines < height + 25 || nlines > height * 3 + 50 || linepos == BUF_BEGV (b)) { ptrdiff_t limit = BUF_BEGV (b); ptrdiff_t limit_byte = BUF_BEGV_BYTE (b); ptrdiff_t position; ptrdiff_t distance = (height * 2 + 30) * line_number_display_limit_width; if (startpos - distance > limit) { limit = startpos - distance; limit_byte = CHAR_TO_BYTE (limit); } nlines = display_count_lines (startpos_byte, limit_byte, - (height * 2 + 30), &position); /* If we couldn't find the lines we wanted within line_number_display_limit_width chars per line, give up on line numbers for this window. */ if (position == limit_byte && limit == startpos - distance) { w->base_line_pos = -1; w->base_line_number = 0; goto no_value; } w->base_line_number = topline - nlines; w->base_line_pos = BYTE_TO_CHAR (position); } /* Now count lines from the start pos to point. */ nlines = display_count_lines (startpos_byte, PT_BYTE, PT, &junk); /* Record that we did display the line number. */ line_number_displayed = true; /* Make the string to show. */ pint2str (decode_mode_spec_buf, width, topline + nlines); return decode_mode_spec_buf; no_value: { char *p = decode_mode_spec_buf; int pad = width - 2; while (pad-- > 0) *p++ = ' '; *p++ = '?'; *p++ = '?'; *p = '\0'; return decode_mode_spec_buf; } } break; } if (STRINGP (obj)) { *string = obj; return SSDATA (obj); } else return ""; } DEFUN ("line-number-at-position", Fline_number_at_position, Sline_number_at_position, 1, 2, 0, doc: /* Return line number at position. */) (Lisp_Object window, Lisp_Object pos) { struct window *w = decode_live_window (window); Lisp_Object buf; struct buffer *b; buf = w->contents; CHECK_BUFFER (buf); b = XBUFFER (buf); struct buffer *old_buffer = NULL; Lisp_Object foo_string; const char *spec; EMACS_INT opoint; EMACS_INT posint; Lisp_Object value; if (b != current_buffer) { old_buffer = current_buffer; set_buffer_internal (b); } if (!NILP (pos)) { opoint = PT; posint = XINT (pos); SET_PT (posint); } spec = internal_line_number_at_position (w, 'l', 0, &foo_string); if (!NILP (pos)) SET_PT (opoint); if (old_buffer) set_buffer_internal (old_buffer); value = build_string (spec); value = Fstring_to_number (value, make_number (10)); return value; } DEFSYM (Qline_number_at_position, "line-number-at-position"); From unknown Tue Jun 17 22:28:10 2025 X-Loop: help-debbugs@gnu.org Subject: bug#22763: 25.1.50; Feature Request -- A faster method to obtain line number at position. Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 22 Feb 2016 16:07:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 22763 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: Keith David Bershatsky Cc: 22763@debbugs.gnu.org Reply-To: Eli Zaretskii Received: via spool by 22763-submit@debbugs.gnu.org id=B22763.145615721923088 (code B ref 22763); Mon, 22 Feb 2016 16:07:02 +0000 Received: (at 22763) by debbugs.gnu.org; 22 Feb 2016 16:06:59 +0000 Received: from localhost ([127.0.0.1]:38250 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84) (envelope-from ) id 1aXt0l-00060J-8g for submit@debbugs.gnu.org; Mon, 22 Feb 2016 11:06:59 -0500 Received: from eggs.gnu.org ([208.118.235.92]:52487) by debbugs.gnu.org with esmtp (Exim 4.84) (envelope-from ) id 1aXt0j-000607-TZ for 22763@debbugs.gnu.org; Mon, 22 Feb 2016 11:06:58 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aXt0Z-0003dS-1L for 22763@debbugs.gnu.org; Mon, 22 Feb 2016 11:06:52 -0500 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=0.8 required=5.0 tests=BAYES_50,RP_MATCHES_RCVD autolearn=disabled version=3.3.2 Received: from fencepost.gnu.org ([2001:4830:134:3::e]:38609) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aXt0Y-0003dN-UP; Mon, 22 Feb 2016 11:06:46 -0500 Received: from 84.94.185.246.cable.012.net.il ([84.94.185.246]:1191 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_128_CBC_SHA1:128) (Exim 4.82) (envelope-from ) id 1aXt0Y-0001HS-0Q; Mon, 22 Feb 2016 11:06:46 -0500 Date: Mon, 22 Feb 2016 18:06:37 +0200 Message-Id: <83y4aclofm.fsf@gnu.org> From: Eli Zaretskii In-reply-to: (message from Keith David Bershatsky on Sun, 21 Feb 2016 18:42:52 -0800) References: 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-Spam-Score: -5.0 (-----) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -5.0 (-----) > Date: Sun, 21 Feb 2016 18:42:52 -0800 > From: Keith David Bershatsky > > A while back, I posed a question on emacs.stackexchange.com for a faster method to obtain `line-number-at-pos`. A user by the name of Constantine came up with `(format-mode-line "%l")`, which is indeed much faster. I think the draft code below may be just a tad faster, with the added feature of the POS argument. > > http://emacs.stackexchange.com/questions/3821/a-faster-method-to-obtain-line-number-at-pos-in-large-buffers > > A user named wasamasa posted a comment: "Be aware that this method will give you "??" for lines exceeding line-number-display-limit-width which is set to a value of 200 per default as I found out here." > > And Stefan posted a comment: "IIRC the result may also be unreliable if there have been modifications in the buffer since the last redisplay." > > The thread has received 555 hits in the past year, and several have star-ed it and up-voted the question and answer. > > The following is a draft in C based on the existing function `decode_mode_spec` that lets the user input the POS as an argument without the necessity to use `goto-char`. I'm not sure if it resolves either of the comments above. The draft is not meant to be a patch per se, because I'm not a programmer and am just beginning my tinkering quest into the language of C. I have been using it in my own setup for about a week and I haven't seen any ill effects. It can of course use some TLC by someone more knowledgeable than myself. This would overwrite the line number and position cached by each window for redisplay purposes. I think this is undesirable. More importantly, the gotchas pointed out above will still be true, AFAICT. My suggestion is instead to expose display_count_lines to Lisp via a simple wrapper (that would need to take care of narrowing and such likes, something that your proposed API doesn't do, btw). In my limited testing I saw a 5- to 10-fold speedup as compared to line-number-at-pos, when doing that. I think this is good enough; applications that need faster massive counting, if there are such applications, can implement a cache in Lisp and speed this up even more. Thanks. From unknown Tue Jun 17 22:28:10 2025 X-Loop: help-debbugs@gnu.org Subject: bug#22763: 25.1.50; Feature Request -- A faster method to obtain line number at position. Resent-From: Lars Ingebrigtsen Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 07 Feb 2021 15:08:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 22763 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: Eli Zaretskii Cc: 22763@debbugs.gnu.org, Keith David Bershatsky Received: via spool by 22763-submit@debbugs.gnu.org id=B22763.161271046212018 (code B ref 22763); Sun, 07 Feb 2021 15:08:02 +0000 Received: (at 22763) by debbugs.gnu.org; 7 Feb 2021 15:07:42 +0000 Received: from localhost ([127.0.0.1]:48465 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1l8lf3-00037m-Lm for submit@debbugs.gnu.org; Sun, 07 Feb 2021 10:07:41 -0500 Received: from quimby.gnus.org ([95.216.78.240]:36812) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1l8lf2-00037X-GT for 22763@debbugs.gnu.org; Sun, 07 Feb 2021 10:07:41 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnus.org; s=20200322; h=Content-Type:MIME-Version:Message-ID:In-Reply-To:Date: References:Subject:Cc:To:From:Sender:Reply-To:Content-Transfer-Encoding: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=qLFJkdD7npwYkcWk/TRQSImd0Su41BqswCgYP7wSF2k=; b=bQ3V10mUTFVjQfoBkM49zPPgEM O74TuDE4ELvWFSiAc5ol6Kjlf6mYT1V6Ly+aFROLvssY2zECA0nxMGLGPwmFbCVdQT2nW2ie0auc0 DeVFgYvSJ7PyqnloZQBY+VTYVwP/RMiRjL78oJQUIa9bO6OIdaZZXRkXRAgAJzaB5w9Q=; Received: from cm-84.212.202.86.getinternet.no ([84.212.202.86] helo=xo) by quimby.gnus.org with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1l8lek-0001cv-Vk; Sun, 07 Feb 2021 16:07:32 +0100 From: Lars Ingebrigtsen References: <83y4aclofm.fsf@gnu.org> X-Now-Playing: Lucy Roleff's _Left Open in a Room_: "Rheingold" Date: Sun, 07 Feb 2021 16:07:21 +0100 In-Reply-To: <83y4aclofm.fsf@gnu.org> (Eli Zaretskii's message of "Mon, 22 Feb 2016 18:06:37 +0200") Message-ID: <878s7z532u.fsf@gnus.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Report: Spam detection software, running on the system "quimby.gnus.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see @@CONTACT_ADDRESS@@ for details. Content preview: Eli Zaretskii writes: > My suggestion is instead to expose display_count_lines to Lisp via a > simple wrapper (that would need to take care of narrowing and such > likes, something that your proposed API doesn't do, btw). Content analysis details: (-2.9 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -1.0 ALL_TRUSTED Passed through trusted hosts only via SMTP -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] X-Spam-Score: 0.0 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) Eli Zaretskii writes: > My suggestion is instead to expose display_count_lines to Lisp via a > simple wrapper (that would need to take care of narrowing and such > likes, something that your proposed API doesn't do, btw). I've now added this to Emacs 28 -- line-number-at-position. In my tests, it makes `count-lines' about 2x faster than the previous implementation. Now, there's a function called `line-number-at-pos' in simple.el (that I've amended to use `line-number-at-position', so it's even faster), and it has almost exactly the signature that the new function has. But it has the POS parameter optional, and it has an ABSOLUTE parameter. I didn't actually discover it before I had finished writing the new function, so I think I'll just extend the new function to have the same signature, and then remove the simple.el function. Unless somebody else has a different opinion in the next ten minutes... -- (domestic pets only, the antidote for overdose, milk.) bloggy blog: http://lars.ingebrigtsen.no From unknown Tue Jun 17 22:28:10 2025 X-Loop: help-debbugs@gnu.org Subject: bug#22763: 25.1.50; Feature Request -- A faster method to obtain line number at position. Resent-From: Lars Ingebrigtsen Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 07 Feb 2021 15:45:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 22763 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: Eli Zaretskii Cc: 22763@debbugs.gnu.org, Keith David Bershatsky Received: via spool by 22763-submit@debbugs.gnu.org id=B22763.161271266215555 (code B ref 22763); Sun, 07 Feb 2021 15:45:02 +0000 Received: (at 22763) by debbugs.gnu.org; 7 Feb 2021 15:44:22 +0000 Received: from localhost ([127.0.0.1]:48522 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1l8mEY-00042p-I0 for submit@debbugs.gnu.org; Sun, 07 Feb 2021 10:44:22 -0500 Received: from quimby.gnus.org ([95.216.78.240]:37104) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1l8mEV-00042X-He for 22763@debbugs.gnu.org; Sun, 07 Feb 2021 10:44:20 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnus.org; s=20200322; h=Content-Type:MIME-Version:Message-ID:In-Reply-To:Date: References:Subject:Cc:To:From:Sender:Reply-To:Content-Transfer-Encoding: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=lSkePcj01Bci5qPz21Pvbcl4EM7LiV5DmkJQ2PIQImo=; b=dwjewVVE355jFtfnZ1UPRPMreW lbu2+DW8JplUhyTqdspfL4c8/VnnsopQOe7VeK+Hi7lmskZ5gZIfuDambN8TnIuNO/Moqi4vOcyim kSv8j6lw+re/4FXyqq5e83xiKm/+82N5OyNLh3vaqnZ8csJgF7qrCxJk4mBSpeePVTCs=; Received: from cm-84.212.202.86.getinternet.no ([84.212.202.86] helo=xo) by quimby.gnus.org with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1l8mEI-0001vK-Kp; Sun, 07 Feb 2021 16:44:12 +0100 From: Lars Ingebrigtsen References: <83y4aclofm.fsf@gnu.org> <878s7z532u.fsf@gnus.org> X-Now-Playing: Brigid Mae Power's _The Bones You Keep Close_: "I told you the truth" Date: Sun, 07 Feb 2021 16:44:05 +0100 In-Reply-To: <878s7z532u.fsf@gnus.org> (Lars Ingebrigtsen's message of "Sun, 07 Feb 2021 16:07:21 +0100") Message-ID: <874kin51dm.fsf@gnus.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Report: Spam detection software, running on the system "quimby.gnus.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see @@CONTACT_ADDRESS@@ for details. Content preview: Lars Ingebrigtsen writes: > Unless somebody else has a different opinion in the next ten minutes... Nope. And now all the tests actually pass, too, which I should have checked before I pushed... Content analysis details: (-2.9 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -1.0 ALL_TRUSTED Passed through trusted hosts only via SMTP -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] X-Spam-Score: 0.0 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) Lars Ingebrigtsen writes: > Unless somebody else has a different opinion in the next ten minutes... Nope. And now all the tests actually pass, too, which I should have checked before I pushed... -- (domestic pets only, the antidote for overdose, milk.) bloggy blog: http://lars.ingebrigtsen.no From debbugs-submit-bounces@debbugs.gnu.org Sun Feb 07 10:44:27 2021 Received: (at control) by debbugs.gnu.org; 7 Feb 2021 15:44:27 +0000 Received: from localhost ([127.0.0.1]:48525 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1l8mEc-000434-Qp for submit@debbugs.gnu.org; Sun, 07 Feb 2021 10:44:27 -0500 Received: from quimby.gnus.org ([95.216.78.240]:37116) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1l8mEb-00042g-By for control@debbugs.gnu.org; Sun, 07 Feb 2021 10:44:25 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnus.org; s=20200322; h=Subject:From:To:Message-Id:Date:Sender:Reply-To:Cc: MIME-Version:Content-Type:Content-Transfer-Encoding:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:In-Reply-To:References:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=IYGzWIIWzlG5ErJICWn6ZF4j21l+DlIXlSYdkLknamY=; b=SRQ+BL54lk3y01/IkL7yxepjVd OeRoiwkz4u7jN9PIStmZ72AxEZhpCLBTBchxTNOSM9N760wzpUXpbpwyTuEnhJDTN5Om6bIxxj+LL 3pz6zN7lpFTMH2lWPJ7gfmfXGSvY/kClfZkIpRFoh06NbxiLSDKGZ8MuBPE7F3+sKSoM=; Received: from cm-84.212.202.86.getinternet.no ([84.212.202.86] helo=xo) by quimby.gnus.org with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1l8mET-0001vR-Ct for control@debbugs.gnu.org; Sun, 07 Feb 2021 16:44:19 +0100 Date: Sun, 07 Feb 2021 16:44:16 +0100 Message-Id: <8735y751db.fsf@gnus.org> To: control@debbugs.gnu.org From: Lars Ingebrigtsen Subject: control message for bug #22763 X-Spam-Report: Spam detection software, running on the system "quimby.gnus.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see @@CONTACT_ADDRESS@@ for details. Content preview: tags 22763 fixed close 22763 28.1 quit Content analysis details: (-2.9 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -1.0 ALL_TRUSTED Passed through trusted hosts only via SMTP -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: control X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) tags 22763 fixed close 22763 28.1 quit From unknown Tue Jun 17 22:28:10 2025 X-Loop: help-debbugs@gnu.org Subject: bug#22763: 25.1.50; Feature Request -- A faster method to obtain line number at position. Resent-From: Lars Ingebrigtsen Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 07 Feb 2021 16:09:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 22763 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: fixed To: Eli Zaretskii Cc: 22763@debbugs.gnu.org, Keith David Bershatsky Received: via spool by 22763-submit@debbugs.gnu.org id=B22763.161271409225863 (code B ref 22763); Sun, 07 Feb 2021 16:09:01 +0000 Received: (at 22763) by debbugs.gnu.org; 7 Feb 2021 16:08:12 +0000 Received: from localhost ([127.0.0.1]:48540 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1l8mbc-0006j5-ML for submit@debbugs.gnu.org; Sun, 07 Feb 2021 11:08:12 -0500 Received: from quimby.gnus.org ([95.216.78.240]:37356) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1l8mba-0006iq-Pv for 22763@debbugs.gnu.org; Sun, 07 Feb 2021 11:08:12 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnus.org; s=20200322; h=Content-Type:MIME-Version:Message-ID:In-Reply-To:Date: References:Subject:Cc:To:From:Sender:Reply-To:Content-Transfer-Encoding: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=bygNj45lmJHzOqbicCL38o+ncF+fE54JNteSPPD67H4=; b=r7p7NUN/VIKSKzCa10KG8TudF9 Opv/Uq4ZES5KhJsKKeFuibpO6xeeZOX+8wOm0ODwPq7T5MSk+eAKkW8MDbkGtndBR+PBG1eENIPQm gJAZxdH76/JkSAk0X4GM/bzJNg1w/B78JjQAJDXcLRUynOP7KENbhcf6JnTJhlAbMR90=; Received: from cm-84.212.202.86.getinternet.no ([84.212.202.86] helo=xo) by quimby.gnus.org with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1l8mbP-00028u-Ke; Sun, 07 Feb 2021 17:08:04 +0100 From: Lars Ingebrigtsen References: <83y4aclofm.fsf@gnu.org> <878s7z532u.fsf@gnus.org> X-Now-Playing: Mia Doi Todd's _Pink Sun EP_: "My Room Is White (Flying Lotus Remix)" Date: Sun, 07 Feb 2021 17:07:57 +0100 In-Reply-To: <878s7z532u.fsf@gnus.org> (Lars Ingebrigtsen's message of "Sun, 07 Feb 2021 16:07:21 +0100") Message-ID: <87y2fz3lpe.fsf@gnus.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Report: Spam detection software, running on the system "quimby.gnus.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see @@CONTACT_ADDRESS@@ for details. Content preview: Lars Ingebrigtsen writes: > I didn't actually discover it before I had finished writing the new > function, so I think I'll just extend the new function to have the same > signature, and then remove the simple.el function. Content analysis details: (-2.9 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -1.0 ALL_TRUSTED Passed through trusted hosts only via SMTP -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] X-Spam-Score: 0.0 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) Lars Ingebrigtsen writes: > I didn't actually discover it before I had finished writing the new > function, so I think I'll just extend the new function to have the same > signature, and then remove the simple.el function. This takes 2.8s in Emacs 27 and 0.3s after the change: (with-temp-buffer (insert-file-contents "~/src/emacs/trunk/src/ChangeLog.11") (benchmark-run 1000 (line-number-at-pos (point-max)))) So that's nice. `line-number-at-pos' is used all over Emacs, but probably not in a loop a lot, so it probably doesn't make much difference, though. -- (domestic pets only, the antidote for overdose, milk.) bloggy blog: http://lars.ingebrigtsen.no From unknown Tue Jun 17 22:28:10 2025 X-Loop: help-debbugs@gnu.org Subject: bug#22763: 25.1.50; Feature Request -- A faster method to obtain line number at position. Resent-From: Stefan Monnier Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 07 Feb 2021 17:41:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 22763 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: fixed To: Lars Ingebrigtsen Cc: 22763@debbugs.gnu.org, Eli Zaretskii , Keith David Bershatsky Received: via spool by 22763-submit@debbugs.gnu.org id=B22763.161271965826630 (code B ref 22763); Sun, 07 Feb 2021 17:41:01 +0000 Received: (at 22763) by debbugs.gnu.org; 7 Feb 2021 17:40:58 +0000 Received: from localhost ([127.0.0.1]:48664 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1l8o3O-0006vS-J4 for submit@debbugs.gnu.org; Sun, 07 Feb 2021 12:40:58 -0500 Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:25247) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1l8o3M-0006vD-17 for 22763@debbugs.gnu.org; Sun, 07 Feb 2021 12:40:57 -0500 Received: from pmg3.iro.umontreal.ca (localhost [127.0.0.1]) by pmg3.iro.umontreal.ca (Proxmox) with ESMTP id 72CBF440126; Sun, 7 Feb 2021 12:40:50 -0500 (EST) Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg3.iro.umontreal.ca (Proxmox) with ESMTP id 02968440BBF; Sun, 7 Feb 2021 12:40:44 -0500 (EST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1612719645; bh=Dv5g85dKVCuzKPR3kuKCO5JbgJCP0YrwL3UZmuOasbM=; h=From:To:Cc:Subject:References:Date:In-Reply-To:From; b=Q2PFM0PaLUqhrrxSHFcXIuXbdQQkzNPjL7+KXiZEsM50DAKrvFWdIng10iFYbDKAs 4gl7Hwh6xj+LcW8TbR8d5aDTDB5EFlB8rkUdwmDhF9r8zjisIQYha73hApTVz/Md56 hkdavEnQXMKAEbEPIkqNG/TJngvOd5EATF1VmXzuWcolsw9n8NFHKAzyr/6R9U0ioH MxfmmBP+Rw3QYipDM4NilRi0GCb18uwPyOalqivB+xCIqB3oX6W0fcM9Pf8UKR6DM4 AjL/eZ0s4R9hXVFm0Y5sQDNiVgI1DFkvoqc/G8TVWvNbCKR1jt8IJaihbK9nXZRpnO nEnMK8IHy6Ilw== Received: from alfajor (unknown [216.154.41.47]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id 91FD9120056; Sun, 7 Feb 2021 12:40:44 -0500 (EST) From: Stefan Monnier Message-ID: References: <83y4aclofm.fsf@gnu.org> <878s7z532u.fsf@gnus.org> <87y2fz3lpe.fsf@gnus.org> Date: Sun, 07 Feb 2021 12:40:43 -0500 In-Reply-To: <87y2fz3lpe.fsf@gnus.org> (Lars Ingebrigtsen's message of "Sun, 07 Feb 2021 17:07:57 +0100") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-SPAM-INFO: Spam detection results: 0 ALL_TRUSTED -1 Passed through trusted hosts only via SMTP AWL -0.088 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DKIM_SIGNED 0.1 Message has a DKIM or DK signature, not necessarily valid DKIM_VALID -0.1 Message has at least one valid DKIM or DK signature DKIM_VALID_AU -0.1 Message has a valid DKIM or DK signature from author's domain X-SPAM-LEVEL: X-Spam-Score: -2.3 (--) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) > This takes 2.8s in Emacs 27 and 0.3s after the change: > > (with-temp-buffer > (insert-file-contents "~/src/emacs/trunk/src/ChangeLog.11") > (benchmark-run 1000 > (line-number-at-pos (point-max)))) > > So that's nice. `line-number-at-pos' is used all over Emacs, but > probably not in a loop a lot, so it probably doesn't make much > difference, though. Why is it faster? Is it still always =CE=98(N) just with a smaller constant (if so, what makes the constant smaller), or does it benefit from some kind of caching (which I fail to see in the code) such that it's O(N) sometimes but much faster other times (and if so, what are the cases that are sped up)? Stefan From unknown Tue Jun 17 22:28:10 2025 X-Loop: help-debbugs@gnu.org Subject: bug#22763: 25.1.50; Feature Request -- A faster method to obtain line number at position. Resent-From: Lars Ingebrigtsen Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 07 Feb 2021 17:47:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 22763 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: fixed To: Stefan Monnier Cc: 22763@debbugs.gnu.org, Eli Zaretskii , Keith David Bershatsky Received: via spool by 22763-submit@debbugs.gnu.org id=B22763.161271997427144 (code B ref 22763); Sun, 07 Feb 2021 17:47:01 +0000 Received: (at 22763) by debbugs.gnu.org; 7 Feb 2021 17:46:14 +0000 Received: from localhost ([127.0.0.1]:48668 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1l8o8T-00073j-7u for submit@debbugs.gnu.org; Sun, 07 Feb 2021 12:46:14 -0500 Received: from quimby.gnus.org ([95.216.78.240]:38212) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1l8o8O-00073K-Vh for 22763@debbugs.gnu.org; Sun, 07 Feb 2021 12:46:11 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnus.org; s=20200322; h=Content-Transfer-Encoding:Content-Type:MIME-Version:Message-ID :In-Reply-To:Date:References:Subject:Cc:To:From:Sender:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=IjGwLEdCpcdFDMJeDk92L9Ajd+M3LvkOvDKHAAl1QS4=; b=Rppqsu/ey44ruLqXoMZ6cgvnqw hOee0jziIw5FgsC/pOqHQTqV8Bkt4aWKFfRkitnO/8tYnv1gDuF3m13HEcXdI26YsLSZwmZCReIU6 mF6IZopxaq4/sv6Ka2R9npGPM7YbOV38nthunXAC3gRLy6q8VVayuTCdFShfDi6QA+S4=; Received: from cm-84.212.202.86.getinternet.no ([84.212.202.86] helo=xo) by quimby.gnus.org with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1l8o88-00034f-Ny; Sun, 07 Feb 2021 18:46:01 +0100 From: Lars Ingebrigtsen References: <83y4aclofm.fsf@gnu.org> <878s7z532u.fsf@gnus.org> <87y2fz3lpe.fsf@gnus.org> Face: iVBORw0KGgoAAAANSUhEUgAAADAAAAAwBAMAAAClLOS0AAAABGdBTUEAALGPC/xhBQAAACBj SFJNAAB6JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3CculE8AAAAD1BMVEUkGRdVIxxoSSek Rh7////0Jn+1AAAAAWJLR0QEj2jZUQAAAAd0SU1FB+UCBQsDEP2ML4UAAAGqSURBVDjLjVOBjcMw CIR0AcALGLJAHe+/2x+4SfrSV1+kuNRnDBxnoo+myuQqrKZ9I+YOv4DwDd9gD3hdNcK89wphEsIp FqHOLJp/6X9j25zc/0AKiC+uQPLN3DMpknMW/yqXgs0DXUQ3lLoxFjurqjOKKoVRdvBXmb6wu2t+ 31TVG7jc2nwDhq4wfPx8p2kMLGITDe7z2pV1A7c5n/SYU+5rsee2zzmH7HOorPSoYp52wEW+E5iD saGxzwDYsuKkCIDKpmLhHHOYPi8AkUZmmzUAxEcCWgR4RhvpfmRJjUZOhmo67MLCyIykDx2OoeUU uPoQ9JA9boFAX904JxzT90yCwEd0quugSyYLHXMWYLMvzpMXMlSgOwuASNqqSxSOss2tiBjtZAzU OkQNS2A/Lo41HwEmxJxhDZ2eI8QQOSnIpeGhxAncJtoe2o9TAzeQsWt0UgAYyVFK/VyKwDnsjCI6 D4K7FyApdtyi9c6yFl2Cg5f0AuN6jJe4as45OD1VqUtoda/Kegt1mhdX8hrxLWldrpSA26VzJv2l +tt9U/aHh8IlDCq1/GM/Y+AwNiS2qcAAAAAldEVYdGRhdGU6Y3JlYXRlADIwMjEtMDItMDVUMTE6 MDM6MTUrMDA6MDAgZXUcAAAAJXRFWHRkYXRlOm1vZGlmeQAyMDIxLTAyLTA1VDExOjAzOjE1KzAw OjAwUTjNoAAAAABJRU5ErkJggg== X-Now-Playing: Mia Doi Todd & Company's _Music for A Midsummer Night's Dream_: "Earthly Happiness" Date: Sun, 07 Feb 2021 18:45:51 +0100 In-Reply-To: (Stefan Monnier's message of "Sun, 07 Feb 2021 12:40:43 -0500") Message-ID: <87h7mn22ls.fsf@gnus.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Report: Spam detection software, running on the system "quimby.gnus.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see @@CONTACT_ADDRESS@@ for details. Content preview: Stefan Monnier writes: > Why is it faster? > > Is it still always =?UTF-8?Q?=CE=98?=(N) just with a smaller constant (if so, what makes > the constant smaller), or does it benefit from some kind of caching > (which I fail to see in the cod [...] Content analysis details: (-2.9 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -1.0 ALL_TRUSTED Passed through trusted hosts only via SMTP -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] X-Spam-Score: 0.0 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) Stefan Monnier writes: > Why is it faster? > > Is it still always =CE=98(N) just with a smaller constant (if so, what ma= kes > the constant smaller), or does it benefit from some kind of caching > (which I fail to see in the code) such that it's O(N) sometimes but much > faster other times (and if so, what are the cases that are sped up)? There's no caching. I guess find_newline is just slow compared to display_count_lines? (How many of these functions do we have in the C layer, anyway?) --=20 (domestic pets only, the antidote for overdose, milk.) bloggy blog: http://lars.ingebrigtsen.no From unknown Tue Jun 17 22:28:10 2025 X-Loop: help-debbugs@gnu.org Subject: bug#22763: 25.1.50; Feature Request -- A faster method to obtain line number at position. Resent-From: Lars Ingebrigtsen Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 07 Feb 2021 18:08:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 22763 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: fixed To: Stefan Monnier Cc: 22763@debbugs.gnu.org, Eli Zaretskii , Keith David Bershatsky Received: via spool by 22763-submit@debbugs.gnu.org id=B22763.16127212424757 (code B ref 22763); Sun, 07 Feb 2021 18:08:01 +0000 Received: (at 22763) by debbugs.gnu.org; 7 Feb 2021 18:07:22 +0000 Received: from localhost ([127.0.0.1]:48694 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1l8oSw-0001Ed-2A for submit@debbugs.gnu.org; Sun, 07 Feb 2021 13:07:22 -0500 Received: from quimby.gnus.org ([95.216.78.240]:38438) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1l8oSu-0001EO-Ic for 22763@debbugs.gnu.org; Sun, 07 Feb 2021 13:07:21 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnus.org; s=20200322; h=Content-Transfer-Encoding:Content-Type:MIME-Version:Message-ID :In-Reply-To:Date:References:Subject:Cc:To:From:Sender:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=OB6QvIapkUupLfoPGXqWGXlpfFYM5+69mNl2DEIPuOs=; b=A60MWFffo1QDRfT5LkJLyAiA1m KZ7uKeBPe7w90GjAYY2XnWnVP+mdms+y5mIkfQFPCpmTGnupTmJflu8XYGU+UPM8C1OKdNXoKXIAT kH6ekEUAQ6NT4V8+tmlBuyspB4VVMm8GGNrPLnal/xfzF6EnTg8O1zJcd/9VUV+FndRc=; Received: from cm-84.212.202.86.getinternet.no ([84.212.202.86] helo=xo) by quimby.gnus.org with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1l8oSk-0003FU-Fz; Sun, 07 Feb 2021 19:07:13 +0100 From: Lars Ingebrigtsen References: <83y4aclofm.fsf@gnu.org> <878s7z532u.fsf@gnus.org> <87y2fz3lpe.fsf@gnus.org> <87h7mn22ls.fsf@gnus.org> Face: iVBORw0KGgoAAAANSUhEUgAAADAAAAAwBAMAAAClLOS0AAAABGdBTUEAALGPC/xhBQAAACBj SFJNAAB6JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3CculE8AAAAD1BMVEUkGRdVIxxoSSek Rh7////0Jn+1AAAAAWJLR0QEj2jZUQAAAAd0SU1FB+UCBQsDEP2ML4UAAAGqSURBVDjLjVOBjcMw CIR0AcALGLJAHe+/2x+4SfrSV1+kuNRnDBxnoo+myuQqrKZ9I+YOv4DwDd9gD3hdNcK89wphEsIp FqHOLJp/6X9j25zc/0AKiC+uQPLN3DMpknMW/yqXgs0DXUQ3lLoxFjurqjOKKoVRdvBXmb6wu2t+ 31TVG7jc2nwDhq4wfPx8p2kMLGITDe7z2pV1A7c5n/SYU+5rsee2zzmH7HOorPSoYp52wEW+E5iD saGxzwDYsuKkCIDKpmLhHHOYPi8AkUZmmzUAxEcCWgR4RhvpfmRJjUZOhmo67MLCyIykDx2OoeUU uPoQ9JA9boFAX904JxzT90yCwEd0quugSyYLHXMWYLMvzpMXMlSgOwuASNqqSxSOss2tiBjtZAzU OkQNS2A/Lo41HwEmxJxhDZ2eI8QQOSnIpeGhxAncJtoe2o9TAzeQsWt0UgAYyVFK/VyKwDnsjCI6 D4K7FyApdtyi9c6yFl2Cg5f0AuN6jJe4as45OD1VqUtoda/Kegt1mhdX8hrxLWldrpSA26VzJv2l +tt9U/aHh8IlDCq1/GM/Y+AwNiS2qcAAAAAldEVYdGRhdGU6Y3JlYXRlADIwMjEtMDItMDVUMTE6 MDM6MTUrMDA6MDAgZXUcAAAAJXRFWHRkYXRlOm1vZGlmeQAyMDIxLTAyLTA1VDExOjAzOjE1KzAw OjAwUTjNoAAAAABJRU5ErkJggg== X-Now-Playing: Mia Doi Todd & Company's _Music for A Midsummer Night's Dream_: "Great Love Theme in Flute" Date: Sun, 07 Feb 2021 19:07:08 +0100 In-Reply-To: <87h7mn22ls.fsf@gnus.org> (Lars Ingebrigtsen's message of "Sun, 07 Feb 2021 18:45:51 +0100") Message-ID: <8735y721mb.fsf@gnus.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Report: Spam detection software, running on the system "quimby.gnus.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see @@CONTACT_ADDRESS@@ for details. Content preview: Lars Ingebrigtsen writes: > Stefan Monnier writes: > >> Why is it faster? >> >> Is it still always =?UTF-8?Q?=CE=98?=(N) just with a smaller constant (if so, what makes >> the constant smaller), or does it benefit f [...] Content analysis details: (-2.9 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -1.0 ALL_TRUSTED Passed through trusted hosts only via SMTP -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] X-Spam-Score: 0.0 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) Lars Ingebrigtsen writes: > Stefan Monnier writes: > >> Why is it faster? >> >> Is it still always =CE=98(N) just with a smaller constant (if so, what m= akes >> the constant smaller), or does it benefit from some kind of caching >> (which I fail to see in the code) such that it's O(N) sometimes but much >> faster other times (and if so, what are the cases that are sped up)? > > There's no caching. I guess find_newline is just slow compared to > display_count_lines? (How many of these functions do we have in the C > layer, anyway?) Oh, I see that find_newline has a lot of caching going on, and the logic isn't... quite... obvious. I guess it's possible there may be cases where the new implementation is slower, then? I'm not sure how to measure that, though -- it takes 10x more time to call the old `line-number-at-pos' ten times, so if the function is supposed to cache something, it's not doing that. --=20 (domestic pets only, the antidote for overdose, milk.) bloggy blog: http://lars.ingebrigtsen.no From unknown Tue Jun 17 22:28:10 2025 X-Loop: help-debbugs@gnu.org Subject: bug#22763: 25.1.50; Feature Request -- A faster method to obtain line number at position. Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 07 Feb 2021 18:10:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 22763 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: fixed To: Lars Ingebrigtsen Cc: 22763@debbugs.gnu.org, esq@lawlist.com, monnier@iro.umontreal.ca Received: via spool by 22763-submit@debbugs.gnu.org id=B22763.16127213984993 (code B ref 22763); Sun, 07 Feb 2021 18:10:01 +0000 Received: (at 22763) by debbugs.gnu.org; 7 Feb 2021 18:09:58 +0000 Received: from localhost ([127.0.0.1]:48703 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1l8oVR-0001IT-UV for submit@debbugs.gnu.org; Sun, 07 Feb 2021 13:09:58 -0500 Received: from eggs.gnu.org ([209.51.188.92]:34194) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1l8oVP-0001IF-Ii for 22763@debbugs.gnu.org; Sun, 07 Feb 2021 13:09:57 -0500 Received: from fencepost.gnu.org ([2001:470:142:3::e]:34107) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1l8oVJ-0006an-P1; Sun, 07 Feb 2021 13:09:49 -0500 Received: from 84.94.185.95.cable.012.net.il ([84.94.185.95]:2620 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1l8oVI-0002Rf-SR; Sun, 07 Feb 2021 13:09:49 -0500 Date: Sun, 07 Feb 2021 20:09:59 +0200 Message-Id: <83eehrn408.fsf@gnu.org> From: Eli Zaretskii In-Reply-To: <87h7mn22ls.fsf@gnus.org> (message from Lars Ingebrigtsen on Sun, 07 Feb 2021 18:45:51 +0100) References: <83y4aclofm.fsf@gnu.org> <878s7z532u.fsf@gnus.org> <87y2fz3lpe.fsf@gnus.org> <87h7mn22ls.fsf@gnus.org> MIME-version: 1.0 Content-type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Spam-Score: -0.7 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.7 (-) > From: Lars Ingebrigtsen > Cc: Eli Zaretskii , 22763@debbugs.gnu.org, Keith David > Bershatsky > Date: Sun, 07 Feb 2021 18:45:51 +0100 > > Stefan Monnier writes: > > > Why is it faster? > > > > Is it still always Θ(N) just with a smaller constant (if so, what makes > > the constant smaller), or does it benefit from some kind of caching > > (which I fail to see in the code) such that it's O(N) sometimes but much > > faster other times (and if so, what are the cases that are sped up)? > > There's no caching. I guess find_newline is just slow compared to > display_count_lines? find_newline does the same as display_count_lines: it calls memchr. But it also maintains a newline cache. If you disable that cache (by turning of cache-long-scans), you might see a different speedup. Also, calling forward-line would loop in Lisp, not in C. From unknown Tue Jun 17 22:28:10 2025 X-Loop: help-debbugs@gnu.org Subject: bug#22763: 25.1.50; Feature Request -- A faster method to obtain line number at position. Resent-From: Lars Ingebrigtsen Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 07 Feb 2021 18:15:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 22763 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: fixed To: Eli Zaretskii Cc: 22763@debbugs.gnu.org, esq@lawlist.com, monnier@iro.umontreal.ca Received: via spool by 22763-submit@debbugs.gnu.org id=B22763.16127216625420 (code B ref 22763); Sun, 07 Feb 2021 18:15:02 +0000 Received: (at 22763) by debbugs.gnu.org; 7 Feb 2021 18:14:22 +0000 Received: from localhost ([127.0.0.1]:48712 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1l8oZh-0001PK-Qd for submit@debbugs.gnu.org; Sun, 07 Feb 2021 13:14:22 -0500 Received: from quimby.gnus.org ([95.216.78.240]:38498) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1l8oZe-0001P7-Tw for 22763@debbugs.gnu.org; Sun, 07 Feb 2021 13:14:20 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnus.org; s=20200322; h=Content-Type:MIME-Version:Message-ID:In-Reply-To:Date: References:Subject:Cc:To:From:Sender:Reply-To:Content-Transfer-Encoding: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=b5SL9eJcJIo2GmOjPFFfXiSiyiZm6gatL9aAK68nqhI=; b=Xcb7QI/iPyWRlDolezQiLXysHU UvhXO0Gwz/SAV3LopKR+gd5qiij2vMZ4EJ92tQ8eVvRaDi7r2ul9jxVw1m19AfOFjS0Lt/W0EkEdS I41Mr4Orly22Erjon6ovD1UEfe4seQtddzp37b4qHyWUWopSqG2sOEDAnJyMY+9H4488=; Received: from cm-84.212.202.86.getinternet.no ([84.212.202.86] helo=xo) by quimby.gnus.org with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1l8oZV-0003L4-Jz; Sun, 07 Feb 2021 19:14:12 +0100 From: Lars Ingebrigtsen References: <83y4aclofm.fsf@gnu.org> <878s7z532u.fsf@gnus.org> <87y2fz3lpe.fsf@gnus.org> <87h7mn22ls.fsf@gnus.org> <83eehrn408.fsf@gnu.org> Face: iVBORw0KGgoAAAANSUhEUgAAADAAAAAwBAMAAAClLOS0AAAABGdBTUEAALGPC/xhBQAAACBj SFJNAAB6JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3CculE8AAAAD1BMVEUkGRdVIxxoSSek Rh7////0Jn+1AAAAAWJLR0QEj2jZUQAAAAd0SU1FB+UCBQsDEP2ML4UAAAGqSURBVDjLjVOBjcMw CIR0AcALGLJAHe+/2x+4SfrSV1+kuNRnDBxnoo+myuQqrKZ9I+YOv4DwDd9gD3hdNcK89wphEsIp FqHOLJp/6X9j25zc/0AKiC+uQPLN3DMpknMW/yqXgs0DXUQ3lLoxFjurqjOKKoVRdvBXmb6wu2t+ 31TVG7jc2nwDhq4wfPx8p2kMLGITDe7z2pV1A7c5n/SYU+5rsee2zzmH7HOorPSoYp52wEW+E5iD saGxzwDYsuKkCIDKpmLhHHOYPi8AkUZmmzUAxEcCWgR4RhvpfmRJjUZOhmo67MLCyIykDx2OoeUU uPoQ9JA9boFAX904JxzT90yCwEd0quugSyYLHXMWYLMvzpMXMlSgOwuASNqqSxSOss2tiBjtZAzU OkQNS2A/Lo41HwEmxJxhDZ2eI8QQOSnIpeGhxAncJtoe2o9TAzeQsWt0UgAYyVFK/VyKwDnsjCI6 D4K7FyApdtyi9c6yFl2Cg5f0AuN6jJe4as45OD1VqUtoda/Kegt1mhdX8hrxLWldrpSA26VzJv2l +tt9U/aHh8IlDCq1/GM/Y+AwNiS2qcAAAAAldEVYdGRhdGU6Y3JlYXRlADIwMjEtMDItMDVUMTE6 MDM6MTUrMDA6MDAgZXUcAAAAJXRFWHRkYXRlOm1vZGlmeQAyMDIxLTAyLTA1VDExOjAzOjE1KzAw OjAwUTjNoAAAAABJRU5ErkJggg== X-Now-Playing: Mia Doi Todd & Company's _Music for A Midsummer Night's Dream_: "Fairy Time" Date: Sun, 07 Feb 2021 19:14:08 +0100 In-Reply-To: <83eehrn408.fsf@gnu.org> (Eli Zaretskii's message of "Sun, 07 Feb 2021 20:09:59 +0200") Message-ID: <87y2fzzqxb.fsf@gnus.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Report: Spam detection software, running on the system "quimby.gnus.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see @@CONTACT_ADDRESS@@ for details. Content preview: Eli Zaretskii writes: >> There's no caching. I guess find_newline is just slow compared to >> display_count_lines? > > find_newline does the same as display_count_lines: it calls memchr. > But it also maintains a newline c [...] Content analysis details: (-2.9 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -1.0 ALL_TRUSTED Passed through trusted hosts only via SMTP -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] X-Spam-Score: 0.0 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) Eli Zaretskii writes: >> There's no caching. I guess find_newline is just slow compared to >> display_count_lines? > > find_newline does the same as display_count_lines: it calls memchr. > But it also maintains a newline cache. If you disable that cache (by > turning of cache-long-scans), you might see a different speedup. Shouldn't the cache speed things up? Hm... perhaps I'm not getting a newline cache in my tests because I'm using a temp buffer or something? > Also, calling forward-line would loop in Lisp, not in C. No, it cleverly loops in C by calling `forward-line' this way to count lines: (- (buffer-size) (forward-line (buffer-size))) -- (domestic pets only, the antidote for overdose, milk.) bloggy blog: http://lars.ingebrigtsen.no From unknown Tue Jun 17 22:28:10 2025 X-Loop: help-debbugs@gnu.org Subject: bug#22763: 25.1.50; Feature Request -- A faster method to obtain line number at position. Resent-From: Lars Ingebrigtsen Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 07 Feb 2021 18:25:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 22763 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: fixed To: Eli Zaretskii Cc: 22763@debbugs.gnu.org, esq@lawlist.com, monnier@iro.umontreal.ca Received: via spool by 22763-submit@debbugs.gnu.org id=B22763.16127222606402 (code B ref 22763); Sun, 07 Feb 2021 18:25:02 +0000 Received: (at 22763) by debbugs.gnu.org; 7 Feb 2021 18:24:20 +0000 Received: from localhost ([127.0.0.1]:48731 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1l8ojL-0001fC-OW for submit@debbugs.gnu.org; Sun, 07 Feb 2021 13:24:19 -0500 Received: from quimby.gnus.org ([95.216.78.240]:38556) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1l8ojK-0001ey-0A for 22763@debbugs.gnu.org; Sun, 07 Feb 2021 13:24:18 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnus.org; s=20200322; h=Content-Type:MIME-Version:Message-ID:In-Reply-To:Date: References:Subject:Cc:To:From:Sender:Reply-To:Content-Transfer-Encoding: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=0uCn55e6D9lqfYmyzuD7SglwBNtOuXvduy+28uQf43M=; b=BwpBKQ9ribtuPBR4nDP92OKZAS IhwkJaFptyU6u1a1ejQN3LRuqaLGzIXrVvFs7N7aImLQ+X0Otuix+UVyAE0+FG16Y1pP6gyY6m5ZJ rECmiFlrMf0P08GoV2j1eUeD3Zd224p9qxZiikD8CBTmDLuWoLqPYCE1qvNpdN3VXi2s=; Received: from cm-84.212.202.86.getinternet.no ([84.212.202.86] helo=xo) by quimby.gnus.org with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1l8oiw-0003Q1-4c; Sun, 07 Feb 2021 19:24:04 +0100 From: Lars Ingebrigtsen References: <83y4aclofm.fsf@gnu.org> <878s7z532u.fsf@gnus.org> <87y2fz3lpe.fsf@gnus.org> <87h7mn22ls.fsf@gnus.org> <83eehrn408.fsf@gnu.org> <87y2fzzqxb.fsf@gnus.org> Face: iVBORw0KGgoAAAANSUhEUgAAADAAAAAwBAMAAAClLOS0AAAABGdBTUEAALGPC/xhBQAAACBj SFJNAAB6JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3CculE8AAAAD1BMVEUkGRdVIxxoSSek Rh7////0Jn+1AAAAAWJLR0QEj2jZUQAAAAd0SU1FB+UCBQsDEP2ML4UAAAGqSURBVDjLjVOBjcMw CIR0AcALGLJAHe+/2x+4SfrSV1+kuNRnDBxnoo+myuQqrKZ9I+YOv4DwDd9gD3hdNcK89wphEsIp FqHOLJp/6X9j25zc/0AKiC+uQPLN3DMpknMW/yqXgs0DXUQ3lLoxFjurqjOKKoVRdvBXmb6wu2t+ 31TVG7jc2nwDhq4wfPx8p2kMLGITDe7z2pV1A7c5n/SYU+5rsee2zzmH7HOorPSoYp52wEW+E5iD saGxzwDYsuKkCIDKpmLhHHOYPi8AkUZmmzUAxEcCWgR4RhvpfmRJjUZOhmo67MLCyIykDx2OoeUU uPoQ9JA9boFAX904JxzT90yCwEd0quugSyYLHXMWYLMvzpMXMlSgOwuASNqqSxSOss2tiBjtZAzU OkQNS2A/Lo41HwEmxJxhDZ2eI8QQOSnIpeGhxAncJtoe2o9TAzeQsWt0UgAYyVFK/VyKwDnsjCI6 D4K7FyApdtyi9c6yFl2Cg5f0AuN6jJe4as45OD1VqUtoda/Kegt1mhdX8hrxLWldrpSA26VzJv2l +tt9U/aHh8IlDCq1/GM/Y+AwNiS2qcAAAAAldEVYdGRhdGU6Y3JlYXRlADIwMjEtMDItMDVUMTE6 MDM6MTUrMDA6MDAgZXUcAAAAJXRFWHRkYXRlOm1vZGlmeQAyMDIxLTAyLTA1VDExOjAzOjE1KzAw OjAwUTjNoAAAAABJRU5ErkJggg== X-Now-Playing: Mia Doi Todd & Company's _Music for A Midsummer Night's Dream_: "We Are Love" Date: Sun, 07 Feb 2021 19:23:53 +0100 In-Reply-To: <87y2fzzqxb.fsf@gnus.org> (Lars Ingebrigtsen's message of "Sun, 07 Feb 2021 19:14:08 +0100") Message-ID: <87tuqnzqh2.fsf@gnus.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Report: Spam detection software, running on the system "quimby.gnus.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see @@CONTACT_ADDRESS@@ for details. Content preview: Lars Ingebrigtsen writes: >> find_newline does the same as display_count_lines: it calls memchr. >> But it also maintains a newline cache. If you disable that cache (by >> turning of cache-long-scans), you might see a differen [...] Content analysis details: (-2.9 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -1.0 ALL_TRUSTED Passed through trusted hosts only via SMTP -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] X-Spam-Score: 0.0 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) Lars Ingebrigtsen writes: >> find_newline does the same as display_count_lines: it calls memchr. >> But it also maintains a newline cache. If you disable that cache (by >> turning of cache-long-scans), you might see a different speedup. > > Shouldn't the cache speed things up? No, you're right -- if I set `cache-long-scans' to nil and `line-number-at-pos' in Emacs 27 becomes ~8x faster in my test, which is currently (with-temp-buffer (setq cache-long-scans nil) (dotimes (_ 1000) (insert-file-contents "~/src/emacs/trunk/src/ChangeLog.11") (goto-char (point-max))) (benchmark-run 1 (dotimes (i 1000) (goto-char (/ (buffer-size) 1000)) (line-number-at-pos (point))))) -- (domestic pets only, the antidote for overdose, milk.) bloggy blog: http://lars.ingebrigtsen.no From unknown Tue Jun 17 22:28:10 2025 X-Loop: help-debbugs@gnu.org Subject: bug#22763: 25.1.50; Feature Request -- A faster method to obtain line number at position. Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 07 Feb 2021 19:03:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 22763 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: fixed To: Lars Ingebrigtsen Cc: 22763@debbugs.gnu.org, esq@lawlist.com, monnier@iro.umontreal.ca Received: via spool by 22763-submit@debbugs.gnu.org id=B22763.161272454926451 (code B ref 22763); Sun, 07 Feb 2021 19:03:02 +0000 Received: (at 22763) by debbugs.gnu.org; 7 Feb 2021 19:02:29 +0000 Received: from localhost ([127.0.0.1]:48809 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1l8pKH-0006sY-9o for submit@debbugs.gnu.org; Sun, 07 Feb 2021 14:02:29 -0500 Received: from eggs.gnu.org ([209.51.188.92]:44528) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1l8pKF-0006sM-F4 for 22763@debbugs.gnu.org; Sun, 07 Feb 2021 14:02:28 -0500 Received: from fencepost.gnu.org ([2001:470:142:3::e]:35407) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1l8pK9-00050E-JP; Sun, 07 Feb 2021 14:02:21 -0500 Received: from 84.94.185.95.cable.012.net.il ([84.94.185.95]:2018 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1l8pK1-0004SZ-2K; Sun, 07 Feb 2021 14:02:16 -0500 Date: Sun, 07 Feb 2021 21:02:25 +0200 Message-Id: <83blcvn1ku.fsf@gnu.org> From: Eli Zaretskii In-Reply-To: <87tuqnzqh2.fsf@gnus.org> (message from Lars Ingebrigtsen on Sun, 07 Feb 2021 19:23:53 +0100) References: <83y4aclofm.fsf@gnu.org> <878s7z532u.fsf@gnus.org> <87y2fz3lpe.fsf@gnus.org> <87h7mn22ls.fsf@gnus.org> <83eehrn408.fsf@gnu.org> <87y2fzzqxb.fsf@gnus.org> <87tuqnzqh2.fsf@gnus.org> X-Spam-Score: -0.7 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.7 (-) > From: Lars Ingebrigtsen > Cc: 22763@debbugs.gnu.org, esq@lawlist.com, monnier@iro.umontreal.ca > Date: Sun, 07 Feb 2021 19:23:53 +0100 > > Lars Ingebrigtsen writes: > > >> find_newline does the same as display_count_lines: it calls memchr. > >> But it also maintains a newline cache. If you disable that cache (by > >> turning of cache-long-scans), you might see a different speedup. > > > > Shouldn't the cache speed things up? > > No, you're right -- if I set `cache-long-scans' to nil and > `line-number-at-pos' in Emacs 27 becomes ~8x faster in my test, which is > currently > > (with-temp-buffer > (setq cache-long-scans nil) > (dotimes (_ 1000) > (insert-file-contents "~/src/emacs/trunk/src/ChangeLog.11") > (goto-char (point-max))) > (benchmark-run 1 > (dotimes (i 1000) > (goto-char (/ (buffer-size) 1000)) > (line-number-at-pos (point))))) This benchmark is not very fair. For starters, 1 thousands of ChangeLog.11's size is on line 31 of the file, so you have just 31 lines to count. And those lines are quite short. Try counting a much larger number of lines, and make the lines longer. Then you may see different results. It is also interesting to compare the first iterations with all the rest, when the newlines are already cached. But in general, the raw speed of memchr is very hard to beat, especially given that using the cache requires calls to CHAR_TO_BYTE and BYTE_TO_CHAR, which can be expensive. From unknown Tue Jun 17 22:28:10 2025 X-Loop: help-debbugs@gnu.org Subject: bug#22763: 25.1.50; Feature Request -- A faster method to obtain line number at position. Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 07 Feb 2021 19:07:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 22763 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: fixed To: larsi@gnus.org Cc: 22763@debbugs.gnu.org, esq@lawlist.com, monnier@iro.umontreal.ca Received: via spool by 22763-submit@debbugs.gnu.org id=B22763.161272478726870 (code B ref 22763); Sun, 07 Feb 2021 19:07:01 +0000 Received: (at 22763) by debbugs.gnu.org; 7 Feb 2021 19:06:27 +0000 Received: from localhost ([127.0.0.1]:48829 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1l8pO7-0006zJ-D8 for submit@debbugs.gnu.org; Sun, 07 Feb 2021 14:06:27 -0500 Received: from eggs.gnu.org ([209.51.188.92]:45232) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1l8pO6-0006z2-6C for 22763@debbugs.gnu.org; Sun, 07 Feb 2021 14:06:26 -0500 Received: from fencepost.gnu.org ([2001:470:142:3::e]:35503) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1l8pO1-0006kr-2A; Sun, 07 Feb 2021 14:06:21 -0500 Received: from 84.94.185.95.cable.012.net.il ([84.94.185.95]:2267 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1l8pNu-0008OW-Df; Sun, 07 Feb 2021 14:06:17 -0500 Date: Sun, 07 Feb 2021 21:06:23 +0200 Message-Id: <838s7zn1e8.fsf@gnu.org> From: Eli Zaretskii In-Reply-To: <83blcvn1ku.fsf@gnu.org> (message from Eli Zaretskii on Sun, 07 Feb 2021 21:02:25 +0200) References: <83y4aclofm.fsf@gnu.org> <878s7z532u.fsf@gnus.org> <87y2fz3lpe.fsf@gnus.org> <87h7mn22ls.fsf@gnus.org> <83eehrn408.fsf@gnu.org> <87y2fzzqxb.fsf@gnus.org> <87tuqnzqh2.fsf@gnus.org> <83blcvn1ku.fsf@gnu.org> X-Spam-Score: -0.7 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.7 (-) > Date: Sun, 07 Feb 2021 21:02:25 +0200 > From: Eli Zaretskii > Cc: 22763@debbugs.gnu.org, esq@lawlist.com, monnier@iro.umontreal.ca > > This benchmark is not very fair. For starters, 1 thousands of > ChangeLog.11's size is on line 31 of the file, so you have just 31 > lines to count. And those lines are quite short. Oops, I now see that you insert the file 1000 times, so it's 31 thousand lines. Still, not a very large number, and the lines are very short. From unknown Tue Jun 17 22:28:10 2025 X-Loop: help-debbugs@gnu.org Subject: bug#22763: 25.1.50; Feature Request -- A faster method to obtain line number at position. Resent-From: Lars Ingebrigtsen Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 07 Feb 2021 19:27:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 22763 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: fixed To: Eli Zaretskii Cc: 22763@debbugs.gnu.org, esq@lawlist.com, monnier@iro.umontreal.ca Received: via spool by 22763-submit@debbugs.gnu.org id=B22763.16127259704351 (code B ref 22763); Sun, 07 Feb 2021 19:27:01 +0000 Received: (at 22763) by debbugs.gnu.org; 7 Feb 2021 19:26:10 +0000 Received: from localhost ([127.0.0.1]:48847 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1l8phB-000185-QJ for submit@debbugs.gnu.org; Sun, 07 Feb 2021 14:26:10 -0500 Received: from quimby.gnus.org ([95.216.78.240]:39008) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1l8ph6-00017O-UB for 22763@debbugs.gnu.org; Sun, 07 Feb 2021 14:26:08 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnus.org; s=20200322; h=Content-Type:MIME-Version:Message-ID:In-Reply-To:Date: References:Subject:Cc:To:From:Sender:Reply-To:Content-Transfer-Encoding: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=GKJy3oafyg87Lges2sSK19WCLIL/YrfbhmxBu53Ur5Y=; b=qQX1nUnVTlY36cUfjsFkCCNOkf QmZ2P5ruRXa0PC7K8HF81pPeYEZq1hW+RPw5JgEMm9L3YBEVMYmd41IhKLBcy5UxUgeCpHrODE8SV V5jVyahTe3t8+wUJetxA7bvLPZCCiX6JPjvstjmTkti2W6vkWxiagEjlTPbTIQpTCyIs=; Received: from cm-84.212.202.86.getinternet.no ([84.212.202.86] helo=xo) by quimby.gnus.org with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1l8pgp-0003yi-8S; Sun, 07 Feb 2021 20:25:50 +0100 From: Lars Ingebrigtsen References: <83y4aclofm.fsf@gnu.org> <878s7z532u.fsf@gnus.org> <87y2fz3lpe.fsf@gnus.org> <87h7mn22ls.fsf@gnus.org> <83eehrn408.fsf@gnu.org> <87y2fzzqxb.fsf@gnus.org> <87tuqnzqh2.fsf@gnus.org> <83blcvn1ku.fsf@gnu.org> Face: iVBORw0KGgoAAAANSUhEUgAAADAAAAAwBAMAAAClLOS0AAAABGdBTUEAALGPC/xhBQAAACBj SFJNAAB6JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3CculE8AAAAIVBMVEXjtZr51qf14cvU pFCtVyFUSitvgkwwLRYbEw5QVy7////QMvvfAAAAAWJLR0QKaND0VgAAAAd0SU1FB+UCBxMGNurK ZH4AAAFvSURBVDjL3ZOxboMwEIbNG0BQd5InSARR1dmHom6VkqvL3lpixzLdI0H3QuS37dkQYppk 69QPYdD/2XcYAWMDQRSFIQ0Ri1aOMY9GVsvoIoJwEhQsJkHr7UksXLI4CxuFnlh5Ikw3Y6GJxLWI OQTx2jeJ6x3FPONp5tWy+ZpqxTyFFGa1EreHDACy13kXEmFA4gBiMzPUI+MkBOoX/8mWjMVHKiQ0 6qMvqMNDBYCaROWXSph5a6pcO5AwxmBHV8Hatq1g117B3FjfE+2/Ew0dN4Wum/qWaIbXOQh9mT5R a0aTbgitmW7cSgrrZi7u8DcCr4X9Cuwn8UsohSPCFwqLDgvjIMMoQIV2LPZbYz6cKDoS42qae3gq +xTHNWzIHB0H4Pl4z7A75wYhp6plKfvSGGYm+m/cqccC+uzdF72Up+Yr3Wawh+7ZE1JKI/Y8p58F cnER0lIe8lwIoXbNJ4leTpSKtqzsboueSZ+TxnOFH8vBtfXt13D9AAAAJXRFWHRkYXRlOmNyZWF0 ZQAyMDIxLTAyLTA3VDE5OjA2OjU0KzAwOjAwOdJNGAAAACV0RVh0ZGF0ZTptb2RpZnkAMjAyMS0w Mi0wN1QxOTowNjo1NCswMDowMEiP9aQAAAAASUVORK5CYII= X-Now-Playing: Julie Driscoll's _1969_: "Those That We Love" Date: Sun, 07 Feb 2021 20:25:45 +0100 In-Reply-To: <83blcvn1ku.fsf@gnu.org> (Eli Zaretskii's message of "Sun, 07 Feb 2021 21:02:25 +0200") Message-ID: <87czxbznly.fsf@gnus.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Report: Spam detection software, running on the system "quimby.gnus.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see @@CONTACT_ADDRESS@@ for details. Content preview: Eli Zaretskii writes: >> (with-temp-buffer >> (setq cache-long-scans nil) >> (dotimes (_ 1000) >> (insert-file-contents "~/src/emacs/trunk/src/ChangeLog.11") >> (goto-char (point-max))) >> (benchmark-run 1 >> (dotimes (i 1 [...] Content analysis details: (-2.9 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -1.0 ALL_TRUSTED Passed through trusted hosts only via SMTP -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] X-Spam-Score: 0.0 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) Eli Zaretskii writes: >> (with-temp-buffer >> (setq cache-long-scans nil) >> (dotimes (_ 1000) >> (insert-file-contents "~/src/emacs/trunk/src/ChangeLog.11") >> (goto-char (point-max))) >> (benchmark-run 1 >> (dotimes (i 1000) >> (goto-char (/ (buffer-size) 1000)) >> (line-number-at-pos (point))))) > > This benchmark is not very fair. For starters, 1 thousands of > ChangeLog.11's size is on line 31 of the file, so you have just 31 > lines to count. And those lines are quite short. Oops, that's not what I meant to test... I meant to skip to 1000 places in the buffer, so that's: (with-temp-buffer (dotimes (_ 1000) (insert-file-contents "~/src/emacs/trunk/src/ChangeLog.11") (goto-char (point-max))) (benchmark-run 1 (dotimes (i 100) (goto-char (* (/ (buffer-size) 100) i)) (line-number-at-pos (point))))) (Adjusted down to 100, because it takes too long.) Let's see... Yup, still 10x faster. > Try counting a much larger number of lines, and make the lines > longer. Then you may see different results. > > It is also interesting to compare the first iterations with all the > rest, when the newlines are already cached. OK, I've now bumped the benchmark-run to 10 (and decreased the buffer size by a factor of 10)... let's see... The new version takes exactly the same amount of time, of course... And so does the old one. Well, it's 10% faster in this? (with-temp-buffer (dotimes (_ 100) (insert-file-contents "~/src/emacs/trunk/src/ChangeLog.11") (goto-char (point-max))) (benchmark-run 10 (dotimes (i 100) (goto-char (* (/ (buffer-size) 100) i)) (line-number-at-pos (point))))) Hm. I guess this doesn't update the newline cache in any useful way? Is that a bug? I haven't actually read the code in the function closely. > But in general, the raw speed of memchr is very hard to beat, > especially given that using the cache requires calls to CHAR_TO_BYTE > and BYTE_TO_CHAR, which can be expensive. So ... it's using the cache is only faster when we have monumentally long lines, since memchr is so fast? And in buffers with lines with normal line lengths, it's 10x slower? That sounds like a rather drastic trade-off. I'll try to whip up a benchmark with really long lines and see what happens. Eli Zaretskii writes: > Oops, I now see that you insert the file 1000 times, so it's 31 > thousand lines. Still, not a very large number, and the lines are > very short. Yes, short lines, but the ChangeLog file is pretty typical... -- (domestic pets only, the antidote for overdose, milk.) bloggy blog: http://lars.ingebrigtsen.no From unknown Tue Jun 17 22:28:10 2025 X-Loop: help-debbugs@gnu.org Subject: bug#22763: 25.1.50; Feature Request -- A faster method to obtain line number at position. Resent-From: Lars Ingebrigtsen Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 07 Feb 2021 19:36:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 22763 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: fixed To: Eli Zaretskii Cc: 22763@debbugs.gnu.org, esq@lawlist.com, monnier@iro.umontreal.ca Received: via spool by 22763-submit@debbugs.gnu.org id=B22763.16127265225216 (code B ref 22763); Sun, 07 Feb 2021 19:36:02 +0000 Received: (at 22763) by debbugs.gnu.org; 7 Feb 2021 19:35:22 +0000 Received: from localhost ([127.0.0.1]:48852 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1l8pq6-0001M3-In for submit@debbugs.gnu.org; Sun, 07 Feb 2021 14:35:22 -0500 Received: from quimby.gnus.org ([95.216.78.240]:39082) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1l8pq3-0001Ll-7o for 22763@debbugs.gnu.org; Sun, 07 Feb 2021 14:35:21 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnus.org; s=20200322; h=Content-Type:MIME-Version:Message-ID:In-Reply-To:Date: References:Subject:Cc:To:From:Sender:Reply-To:Content-Transfer-Encoding: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=4EASxV5qT8lCbv4fXR8VHg0neW56dKF4dz6bZsUwR4Y=; b=MnloI0rk++Q43rDJs/nWNch+ss rjnHj038u5CbK4pvP5wwrDGfG0dBwT2k/gcfoetrQ/RhIQBrfXMsiDekWXTNfiSPfneDJqVuQ0dNb wsroZoTgiBbJScLF5WdADFA6EaihWpvXJF4vG1uy7PhwccXWWcB0d+x+0tvesGmQIW4w=; Received: from cm-84.212.202.86.getinternet.no ([84.212.202.86] helo=xo) by quimby.gnus.org with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1l8pph-000453-BT; Sun, 07 Feb 2021 20:35:05 +0100 From: Lars Ingebrigtsen References: <83y4aclofm.fsf@gnu.org> <878s7z532u.fsf@gnus.org> <87y2fz3lpe.fsf@gnus.org> <87h7mn22ls.fsf@gnus.org> <83eehrn408.fsf@gnu.org> <87y2fzzqxb.fsf@gnus.org> <87tuqnzqh2.fsf@gnus.org> <83blcvn1ku.fsf@gnu.org> <87czxbznly.fsf@gnus.org> Face: iVBORw0KGgoAAAANSUhEUgAAADAAAAAwBAMAAAClLOS0AAAABGdBTUEAALGPC/xhBQAAACBj SFJNAAB6JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3CculE8AAAAIVBMVEXjtZr51qf14cvU pFCtVyFUSitvgkwwLRYbEw5QVy7////QMvvfAAAAAWJLR0QKaND0VgAAAAd0SU1FB+UCBxMGNurK ZH4AAAFvSURBVDjL3ZOxboMwEIbNG0BQd5InSARR1dmHom6VkqvL3lpixzLdI0H3QuS37dkQYppk 69QPYdD/2XcYAWMDQRSFIQ0Ri1aOMY9GVsvoIoJwEhQsJkHr7UksXLI4CxuFnlh5Ikw3Y6GJxLWI OQTx2jeJ6x3FPONp5tWy+ZpqxTyFFGa1EreHDACy13kXEmFA4gBiMzPUI+MkBOoX/8mWjMVHKiQ0 6qMvqMNDBYCaROWXSph5a6pcO5AwxmBHV8Hatq1g117B3FjfE+2/Ew0dN4Wum/qWaIbXOQh9mT5R a0aTbgitmW7cSgrrZi7u8DcCr4X9Cuwn8UsohSPCFwqLDgvjIMMoQIV2LPZbYz6cKDoS42qae3gq +xTHNWzIHB0H4Pl4z7A75wYhp6plKfvSGGYm+m/cqccC+uzdF72Up+Yr3Wawh+7ZE1JKI/Y8p58F cnER0lIe8lwIoXbNJ4leTpSKtqzsboueSZ+TxnOFH8vBtfXt13D9AAAAJXRFWHRkYXRlOmNyZWF0 ZQAyMDIxLTAyLTA3VDE5OjA2OjU0KzAwOjAwOdJNGAAAACV0RVh0ZGF0ZTptb2RpZnkAMjAyMS0w Mi0wN1QxOTowNjo1NCswMDowMEiP9aQAAAAASUVORK5CYII= X-Now-Playing: Julie Driscoll's _1969_: "Walk Down" Date: Sun, 07 Feb 2021 20:34:56 +0100 In-Reply-To: <87czxbznly.fsf@gnus.org> (Lars Ingebrigtsen's message of "Sun, 07 Feb 2021 20:25:45 +0100") Message-ID: <878s7zzn6n.fsf@gnus.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Report: Spam detection software, running on the system "quimby.gnus.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see @@CONTACT_ADDRESS@@ for details. Content preview: Lars Ingebrigtsen writes: > I'll try to whip up a benchmark with really long lines and see what > happens. (with-temp-buffer (dotimes (_ 10000) (insert (make-string (random 4000) ?a) "\n")) (benchmark-run 10 (goto-char (point-min)) (while (not (eobp)) (line-number-at-pos (point)) (forward-line 1)))) Content analysis details: (-2.9 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -1.0 ALL_TRUSTED Passed through trusted hosts only via SMTP -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] X-Spam-Score: 0.0 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) Lars Ingebrigtsen writes: > I'll try to whip up a benchmark with really long lines and see what > happens. (with-temp-buffer (dotimes (_ 10000) (insert (make-string (random 4000) ?a) "\n")) (benchmark-run 10 (goto-char (point-min)) (while (not (eobp)) (line-number-at-pos (point)) (forward-line 1)))) With this, the new version still wins... but only slightly. So the cache does indeed help when we've got long lines (which was the point of the cache, I guess?) -- (domestic pets only, the antidote for overdose, milk.) bloggy blog: http://lars.ingebrigtsen.no From unknown Tue Jun 17 22:28:10 2025 X-Loop: help-debbugs@gnu.org Subject: bug#22763: 25.1.50; Feature Request -- A faster method to obtain line number at position. Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 07 Feb 2021 19:43:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 22763 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: fixed To: Lars Ingebrigtsen Cc: 22763@debbugs.gnu.org, esq@lawlist.com, monnier@iro.umontreal.ca Received: via spool by 22763-submit@debbugs.gnu.org id=B22763.16127269565856 (code B ref 22763); Sun, 07 Feb 2021 19:43:01 +0000 Received: (at 22763) by debbugs.gnu.org; 7 Feb 2021 19:42:36 +0000 Received: from localhost ([127.0.0.1]:48860 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1l8px5-0001WN-Ig for submit@debbugs.gnu.org; Sun, 07 Feb 2021 14:42:36 -0500 Received: from eggs.gnu.org ([209.51.188.92]:51450) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1l8px0-0001W7-Mu for 22763@debbugs.gnu.org; Sun, 07 Feb 2021 14:42:34 -0500 Received: from fencepost.gnu.org ([2001:470:142:3::e]:36340) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1l8pwu-0005bl-Uw; Sun, 07 Feb 2021 14:42:24 -0500 Received: from 84.94.185.95.cable.012.net.il ([84.94.185.95]:4488 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1l8pwu-0006OS-9B; Sun, 07 Feb 2021 14:42:24 -0500 Date: Sun, 07 Feb 2021 21:42:33 +0200 Message-Id: <834kinmzpy.fsf@gnu.org> From: Eli Zaretskii In-Reply-To: <87czxbznly.fsf@gnus.org> (message from Lars Ingebrigtsen on Sun, 07 Feb 2021 20:25:45 +0100) References: <83y4aclofm.fsf@gnu.org> <878s7z532u.fsf@gnus.org> <87y2fz3lpe.fsf@gnus.org> <87h7mn22ls.fsf@gnus.org> <83eehrn408.fsf@gnu.org> <87y2fzzqxb.fsf@gnus.org> <87tuqnzqh2.fsf@gnus.org> <83blcvn1ku.fsf@gnu.org> <87czxbznly.fsf@gnus.org> X-Spam-Score: -0.7 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.7 (-) > From: Lars Ingebrigtsen > Cc: 22763@debbugs.gnu.org, esq@lawlist.com, monnier@iro.umontreal.ca > Date: Sun, 07 Feb 2021 20:25:45 +0100 > > (with-temp-buffer > (dotimes (_ 1000) > (insert-file-contents "~/src/emacs/trunk/src/ChangeLog.11") > (goto-char (point-max))) > (benchmark-run 1 > (dotimes (i 100) > (goto-char (* (/ (buffer-size) 100) i)) > (line-number-at-pos (point))))) > > (Adjusted down to 100, because it takes too long.) Let's see... > > Yup, still 10x faster. This one traverses each 1/100th region of the file just once, no? > OK, I've now bumped the benchmark-run to 10 (and decreased the buffer > size by a factor of 10)... let's see... The new version takes exactly > the same amount of time, of course... > > And so does the old one. Well, it's 10% faster in this? 10% or 10-fold? > (with-temp-buffer > (dotimes (_ 100) > (insert-file-contents "~/src/emacs/trunk/src/ChangeLog.11") > (goto-char (point-max))) > (benchmark-run 10 > (dotimes (i 100) > (goto-char (* (/ (buffer-size) 100) i)) > (line-number-at-pos (point))))) > > Hm. I guess this doesn't update the newline cache in any useful way? Why not? It should. > > But in general, the raw speed of memchr is very hard to beat, > > especially given that using the cache requires calls to CHAR_TO_BYTE > > and BYTE_TO_CHAR, which can be expensive. > > So ... it's using the cache is only faster when we have monumentally > long lines, since memchr is so fast? Yes. > And in buffers with lines with normal line lengths, it's 10x slower? In my benchmarks some years ago it was about twice slower, not 10 times. From unknown Tue Jun 17 22:28:10 2025 X-Loop: help-debbugs@gnu.org Subject: bug#22763: 25.1.50; Feature Request -- A faster method to obtain line number at position. Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 07 Feb 2021 19:44:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 22763 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: fixed To: Lars Ingebrigtsen Cc: 22763@debbugs.gnu.org, esq@lawlist.com, monnier@iro.umontreal.ca Received: via spool by 22763-submit@debbugs.gnu.org id=B22763.16127270355976 (code B ref 22763); Sun, 07 Feb 2021 19:44:02 +0000 Received: (at 22763) by debbugs.gnu.org; 7 Feb 2021 19:43:55 +0000 Received: from localhost ([127.0.0.1]:48864 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1l8pyN-0001YK-Bk for submit@debbugs.gnu.org; Sun, 07 Feb 2021 14:43:55 -0500 Received: from eggs.gnu.org ([209.51.188.92]:51704) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1l8pyL-0001Y6-CI for 22763@debbugs.gnu.org; Sun, 07 Feb 2021 14:43:53 -0500 Received: from fencepost.gnu.org ([2001:470:142:3::e]:36445) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1l8pyG-0006C6-1D; Sun, 07 Feb 2021 14:43:48 -0500 Received: from 84.94.185.95.cable.012.net.il ([84.94.185.95]:4580 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1l8pyF-0006TS-1f; Sun, 07 Feb 2021 14:43:47 -0500 Date: Sun, 07 Feb 2021 21:43:59 +0200 Message-Id: <8335y7mznk.fsf@gnu.org> From: Eli Zaretskii In-Reply-To: <878s7zzn6n.fsf@gnus.org> (message from Lars Ingebrigtsen on Sun, 07 Feb 2021 20:34:56 +0100) References: <83y4aclofm.fsf@gnu.org> <878s7z532u.fsf@gnus.org> <87y2fz3lpe.fsf@gnus.org> <87h7mn22ls.fsf@gnus.org> <83eehrn408.fsf@gnu.org> <87y2fzzqxb.fsf@gnus.org> <87tuqnzqh2.fsf@gnus.org> <83blcvn1ku.fsf@gnu.org> <87czxbznly.fsf@gnus.org> <878s7zzn6n.fsf@gnus.org> X-Spam-Score: -0.7 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.7 (-) > From: Lars Ingebrigtsen > Cc: 22763@debbugs.gnu.org, esq@lawlist.com, monnier@iro.umontreal.ca > Date: Sun, 07 Feb 2021 20:34:56 +0100 > > (with-temp-buffer > (dotimes (_ 10000) > (insert (make-string (random 4000) ?a) "\n")) > (benchmark-run 10 > (goto-char (point-min)) > (while (not (eobp)) > (line-number-at-pos (point)) > (forward-line 1)))) > > With this, the new version still wins... but only slightly. So the > cache does indeed help when we've got long lines (which was the point of > the cache, I guess?) Yes. From unknown Tue Jun 17 22:28:10 2025 X-Loop: help-debbugs@gnu.org Subject: bug#22763: 25.1.50; Feature Request -- A faster method to obtain line number at position. Resent-From: Lars Ingebrigtsen Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 07 Feb 2021 19:47:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 22763 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: fixed To: Eli Zaretskii Cc: 22763@debbugs.gnu.org, esq@lawlist.com, monnier@iro.umontreal.ca Received: via spool by 22763-submit@debbugs.gnu.org id=B22763.16127272216299 (code B ref 22763); Sun, 07 Feb 2021 19:47:02 +0000 Received: (at 22763) by debbugs.gnu.org; 7 Feb 2021 19:47:01 +0000 Received: from localhost ([127.0.0.1]:48872 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1l8q1N-0001dW-28 for submit@debbugs.gnu.org; Sun, 07 Feb 2021 14:47:01 -0500 Received: from quimby.gnus.org ([95.216.78.240]:39202) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1l8q1L-0001dJ-C9 for 22763@debbugs.gnu.org; Sun, 07 Feb 2021 14:46:59 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnus.org; s=20200322; h=Content-Type:MIME-Version:Message-ID:In-Reply-To:Date: References:Subject:Cc:To:From:Sender:Reply-To:Content-Transfer-Encoding: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=aoHH8TR6jv8zix5e/8D1EQ+eXoxYcXmKHoHzkdvXN1I=; b=Kng1fp+8VmXQjyXmLK74q12aec fvTimvUQe1hVnPDXuOZA4isDCedY7s/CRxtBC0tvqOyBKWncKxx1J/fx3Layre5hVJjwFyQflmSdt dJZJGJQI0M9s4r8ywNn+PnehGsjLARDc0ycN88QiQjCuUzxg3ULqdDERDYDy1cylc8jM=; Received: from cm-84.212.202.86.getinternet.no ([84.212.202.86] helo=xo) by quimby.gnus.org with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1l8q11-0004C6-3S; Sun, 07 Feb 2021 20:46:46 +0100 From: Lars Ingebrigtsen References: <83y4aclofm.fsf@gnu.org> <878s7z532u.fsf@gnus.org> <87y2fz3lpe.fsf@gnus.org> <87h7mn22ls.fsf@gnus.org> <83eehrn408.fsf@gnu.org> <87y2fzzqxb.fsf@gnus.org> <87tuqnzqh2.fsf@gnus.org> <83blcvn1ku.fsf@gnu.org> <87czxbznly.fsf@gnus.org> <834kinmzpy.fsf@gnu.org> Face: iVBORw0KGgoAAAANSUhEUgAAADAAAAAwBAMAAAClLOS0AAAABGdBTUEAALGPC/xhBQAAACBj SFJNAAB6JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3CculE8AAAAElBMVEWeeVengF2qh2dZ RjUrIhv///+8ThgcAAAAAWJLR0QF+G/pxwAAAAd0SU1FB+UCBxMrID40i8AAAAGPSURBVDjLhZPt ccMwCIaRnQEkTSCpC6iBAXwH+89U0JcV93olP5Lw+IUXLIELIfgAWwQLAAPB90wHbiSC61+hWHhw CrzTlO9PlRHe/vie1YilbOQGLpe8keCXkU1RsrqYdkLYQEkhuNH5I1/KHCA+QR4g59hbJ7ckBg79 0fNU4w5mnURcVy2bc4yQT+F6fIBStEKCExEnMXDEBgCQhRFu0PslMIXMLnkBNaGVUK4blAlEBOk6 1o5nJaBTCc/uG2i22C9FnKCe9aQbuDyB9iCp0y+4OJQnK2E/XIatFJPIBUvRd2jzqUAuD7/sEtkc 9QZToZUYBOFzjtI2hafg+wE0XxFILhwvpIOERIwqEE7HBGaXzJEw6adCHkCf+JIt8GinoYHXTJoS 6wBuVtJ8VUSslZxdopJWlbd6Fn0lyRQQV4taCVVzFN+Am4DYVoz0zu12ArwWcNBA6kfULSBH1IXR Ne6UG6Z0i7WgjTlvmgFuissUrwXu8a6sbwXFPYDq6g7OfVNi4Psf8HoAtrPyN/gB2wyV1l0kvbkA AAAldEVYdGRhdGU6Y3JlYXRlADIwMjEtMDItMDdUMTk6NDM6MzErMDA6MDD7ddP+AAAAJXRFWHRk YXRlOm1vZGlmeQAyMDIxLTAyLTA3VDE5OjQzOjMxKzAwOjAwiihrQgAAAABJRU5ErkJggg== X-Now-Playing: Laraaji's _Sun Transformations_: "Ocean Flow Zither (Mia Doi Todd Remix)" Date: Sun, 07 Feb 2021 20:46:37 +0100 In-Reply-To: <834kinmzpy.fsf@gnu.org> (Eli Zaretskii's message of "Sun, 07 Feb 2021 21:42:33 +0200") Message-ID: <87zh0fy82q.fsf@gnus.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Report: Spam detection software, running on the system "quimby.gnus.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see @@CONTACT_ADDRESS@@ for details. Content preview: Eli Zaretskii writes: >> (with-temp-buffer >> (dotimes (_ 1000) >> (insert-file-contents "~/src/emacs/trunk/src/ChangeLog.11") >> (goto-char (point-max))) >> (benchmark-run 1 >> (dotimes (i 100) >> (goto-char (* (/ (buffer [...] Content analysis details: (-2.9 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -1.0 ALL_TRUSTED Passed through trusted hosts only via SMTP -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] X-Spam-Score: 0.0 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) Eli Zaretskii writes: >> (with-temp-buffer >> (dotimes (_ 1000) >> (insert-file-contents "~/src/emacs/trunk/src/ChangeLog.11") >> (goto-char (point-max))) >> (benchmark-run 1 >> (dotimes (i 100) >> (goto-char (* (/ (buffer-size) 100) i)) >> (line-number-at-pos (point))))) >> >> (Adjusted down to 100, because it takes too long.) Let's see... >> >> Yup, still 10x faster. > > This one traverses each 1/100th region of the file just once, no? Did I write it wrong again? (dotimes (i 100) (goto-char (* (/ (buffer-size) 100) i)) (line-number-at-pos (point))))) No, that should be the entire buffer, spread out evenly? >> OK, I've now bumped the benchmark-run to 10 (and decreased the buffer >> size by a factor of 10)... let's see... The new version takes exactly >> the same amount of time, of course... >> >> And so does the old one. Well, it's 10% faster in this? > > 10% or 10-fold? 10%. >> And in buffers with lines with normal line lengths, it's 10x slower? > > In my benchmarks some years ago it was about twice slower, not 10 > times. Perhaps memchr has gotten faster over the years? Using larger memory fetches and stuff? -- (domestic pets only, the antidote for overdose, milk.) bloggy blog: http://lars.ingebrigtsen.no From unknown Tue Jun 17 22:28:10 2025 X-Loop: help-debbugs@gnu.org Subject: bug#22763: 25.1.50; Feature Request -- A faster method to obtain line number at position. Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 07 Feb 2021 19:53:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 22763 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: fixed To: Lars Ingebrigtsen Cc: 22763@debbugs.gnu.org, esq@lawlist.com, monnier@iro.umontreal.ca Received: via spool by 22763-submit@debbugs.gnu.org id=B22763.16127275296886 (code B ref 22763); Sun, 07 Feb 2021 19:53:02 +0000 Received: (at 22763) by debbugs.gnu.org; 7 Feb 2021 19:52:09 +0000 Received: from localhost ([127.0.0.1]:48898 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1l8q6L-0001n0-9R for submit@debbugs.gnu.org; Sun, 07 Feb 2021 14:52:09 -0500 Received: from eggs.gnu.org ([209.51.188.92]:53114) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1l8q6J-0001mn-FM for 22763@debbugs.gnu.org; Sun, 07 Feb 2021 14:52:07 -0500 Received: from fencepost.gnu.org ([2001:470:142:3::e]:36633) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1l8q6C-0001cV-6k; Sun, 07 Feb 2021 14:52:01 -0500 Received: from 84.94.185.95.cable.012.net.il ([84.94.185.95]:1107 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1l8q66-0007Ch-TM; Sun, 07 Feb 2021 14:51:58 -0500 Date: Sun, 07 Feb 2021 21:52:07 +0200 Message-Id: <83y2fzlkpk.fsf@gnu.org> From: Eli Zaretskii In-Reply-To: <87zh0fy82q.fsf@gnus.org> (message from Lars Ingebrigtsen on Sun, 07 Feb 2021 20:46:37 +0100) References: <83y4aclofm.fsf@gnu.org> <878s7z532u.fsf@gnus.org> <87y2fz3lpe.fsf@gnus.org> <87h7mn22ls.fsf@gnus.org> <83eehrn408.fsf@gnu.org> <87y2fzzqxb.fsf@gnus.org> <87tuqnzqh2.fsf@gnus.org> <83blcvn1ku.fsf@gnu.org> <87czxbznly.fsf@gnus.org> <834kinmzpy.fsf@gnu.org> <87zh0fy82q.fsf@gnus.org> X-Spam-Score: -0.7 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.7 (-) > From: Lars Ingebrigtsen > Cc: 22763@debbugs.gnu.org, esq@lawlist.com, monnier@iro.umontreal.ca > Date: Sun, 07 Feb 2021 20:46:37 +0100 > > > In my benchmarks some years ago it was about twice slower, not 10 > > times. > > Perhaps memchr has gotten faster over the years? No, it was fast then as well (due to inlining, AFAIR). I think the main factor is the file used to benchmark this stuff. I don't remember what I used. From unknown Tue Jun 17 22:28:10 2025 X-Loop: help-debbugs@gnu.org Subject: bug#22763: 25.1.50; Feature Request -- A faster method to obtain line number at position. Resent-From: Stefan Monnier Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 07 Feb 2021 20:38:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 22763 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: fixed To: Lars Ingebrigtsen Cc: 22763@debbugs.gnu.org, Eli Zaretskii , esq@lawlist.com Received: via spool by 22763-submit@debbugs.gnu.org id=B22763.161273025911213 (code B ref 22763); Sun, 07 Feb 2021 20:38:01 +0000 Received: (at 22763) by debbugs.gnu.org; 7 Feb 2021 20:37:39 +0000 Received: from localhost ([127.0.0.1]:48944 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1l8qoM-0002um-VV for submit@debbugs.gnu.org; Sun, 07 Feb 2021 15:37:39 -0500 Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:20311) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1l8qoK-0002uZ-87 for 22763@debbugs.gnu.org; Sun, 07 Feb 2021 15:37:37 -0500 Received: from pmg3.iro.umontreal.ca (localhost [127.0.0.1]) by pmg3.iro.umontreal.ca (Proxmox) with ESMTP id E58C0440C45; Sun, 7 Feb 2021 15:37:30 -0500 (EST) Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg3.iro.umontreal.ca (Proxmox) with ESMTP id A7FAE440C51; Sun, 7 Feb 2021 15:37:29 -0500 (EST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1612730249; bh=Yn9/Z1ehsH/+fQn46REiqTv1ieXGpEkqaVHA1tzDwcA=; h=From:To:Cc:Subject:References:Date:In-Reply-To:From; b=Vlt08ZZxtrRRTDeT4sIXi5/4nOGvCf2GA12PGdDaI7Al+oVhCnmMsH7oYQJRZz9Cl JV04GA8GpVRWkZzGclHclltNJ8F5lnpJIWdfm6FjyAS9tmTLogN0uHBHRsYhvOyXIT qHB965Ne/yAa9TTBvH0Db77UqkFaMu3gffOPzwSyxCJ8kNftaMMTWUB/72hw9AT7Dz 9lU544G3UbFT8eKgtRSqrGLbdSbawYW1r6czhprWUsVA7Zt3aFgZjMGRmTmu13uDH9 IgHnpdPo/VnWyn2guuaLZZBO5HxzcofoYe0+Cg7QXLy9DqEEpHOpjYiYBUjdB4TCSp gUZfWPKZXmRgw== Received: from alfajor (unknown [216.154.41.47]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id 6D5CC120406; Sun, 7 Feb 2021 15:37:29 -0500 (EST) From: Stefan Monnier Message-ID: References: <83y4aclofm.fsf@gnu.org> <878s7z532u.fsf@gnus.org> <87y2fz3lpe.fsf@gnus.org> <87h7mn22ls.fsf@gnus.org> <83eehrn408.fsf@gnu.org> <87y2fzzqxb.fsf@gnus.org> <87tuqnzqh2.fsf@gnus.org> <83blcvn1ku.fsf@gnu.org> <87czxbznly.fsf@gnus.org> Date: Sun, 07 Feb 2021 15:37:28 -0500 In-Reply-To: <87czxbznly.fsf@gnus.org> (Lars Ingebrigtsen's message of "Sun, 07 Feb 2021 20:25:45 +0100") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-SPAM-INFO: Spam detection results: 0 ALL_TRUSTED -1 Passed through trusted hosts only via SMTP AWL -0.088 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DKIM_SIGNED 0.1 Message has a DKIM or DK signature, not necessarily valid DKIM_VALID -0.1 Message has at least one valid DKIM or DK signature DKIM_VALID_AU -0.1 Message has a valid DKIM or DK signature from author's domain X-SPAM-LEVEL: X-Spam-Score: -2.3 (--) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) > So ... it's using the cache is only faster when we have monumentally > long lines, since memchr is so fast? And in buffers with lines with > normal line lengths, it's 10x slower? That sounds like a rather drastic > trade-off. Yes, the problem is when you have pathologically-long lines (typically, when the whole file has virtually no \n in it, so lines can reach multi-MB lengths). Stefan From unknown Tue Jun 17 22:28:10 2025 X-Loop: help-debbugs@gnu.org Subject: bug#22763: 25.1.50; Feature Request -- A faster method to obtain line number at position. Resent-From: Lars Ingebrigtsen Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 07 Feb 2021 20:43:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 22763 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: fixed To: Stefan Monnier Cc: 22763@debbugs.gnu.org, Eli Zaretskii , esq@lawlist.com Received: via spool by 22763-submit@debbugs.gnu.org id=B22763.161273056211656 (code B ref 22763); Sun, 07 Feb 2021 20:43:02 +0000 Received: (at 22763) by debbugs.gnu.org; 7 Feb 2021 20:42:42 +0000 Received: from localhost ([127.0.0.1]:48948 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1l8qtG-00031v-K7 for submit@debbugs.gnu.org; Sun, 07 Feb 2021 15:42:42 -0500 Received: from quimby.gnus.org ([95.216.78.240]:39676) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1l8qtF-00031i-4T for 22763@debbugs.gnu.org; Sun, 07 Feb 2021 15:42:41 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnus.org; s=20200322; h=Content-Type:MIME-Version:Message-ID:In-Reply-To:Date: References:Subject:Cc:To:From:Sender:Reply-To:Content-Transfer-Encoding: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=DFYgijxmazsaf/j7ouyNsuSmEUgczU2W5U0EJBaoRQc=; b=uvhWKTtJU9eH7u67emTwpmgX28 TEG2yS9amvnXtB/zeqRC76m/hY6wcVdVj0wlo+x/IGn7Rcb0I+qhxAUOdjqV0YFQIh0ch2Zdr0xnI PV3uwoF2rvKt9ratMeojvn302EpdiSbs8K62d+/jOLNppubLCwqAf6SnisugqNVkIAaE=; Received: from cm-84.212.202.86.getinternet.no ([84.212.202.86] helo=xo) by quimby.gnus.org with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1l8qt5-0004is-0B; Sun, 07 Feb 2021 21:42:33 +0100 From: Lars Ingebrigtsen References: <83y4aclofm.fsf@gnu.org> <878s7z532u.fsf@gnus.org> <87y2fz3lpe.fsf@gnus.org> <87h7mn22ls.fsf@gnus.org> <83eehrn408.fsf@gnu.org> <87y2fzzqxb.fsf@gnus.org> <87tuqnzqh2.fsf@gnus.org> <83blcvn1ku.fsf@gnu.org> <87czxbznly.fsf@gnus.org> Face: iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAMAAABg3Am1AAAABGdBTUEAALGPC/xhBQAAACBj SFJNAAB6JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3CculE8AAAAM1BMVEUAAAEWFhUlJSUF AxdOTk4zMTZubmx+f3tgYGGMjYkfHx9NSjczLkUiHDcSDC2ZmDT////IVuXkAAAAAWJLR0QQlbIN LAAAAAd0SU1FB+UCBBYKOcK+W+YAAAFWSURBVEjH7VTbdsIwDKuvNSVp//9vJ6cwyg47NU97GDo0 LUGypaRkmv4IxMxSJbOaKWuOViiNjxBuROMaYHpJZHc1nz0iaGZ1Zw18uThG/PpDFDyRGbNhMCNF CF1QG1PZAwQ9ljfzoAVPad5cNTICBsIz57yj/UMiOmNi9BQgS46B7B6AYr4RbvCL5yraFdazWCgu xzKFZwAQYuajpyC3Qx64iYC7R02b6BhimJlgAJnRRRWr4zGeBnh6iTDNvLgZJAr9TrffBE/bfSmQ nhX0puC96rv1ag9pra9Ai8LLClBbB39tq7aKwNbeQO9r72ur/CFQ2vpO76LngkV66wmFMennuyGS 7AZjXeDs3NPeAG76yoYo5wJYR2z4sW3bloKlXJ9cWLlCUDlrxh6Mndg2Wwr7IHIXwFXp7UhBBk9F 7fSTb0H1tByuQC+frvtpU2d/8ME/hXwB5W8NHHkY9qUAAAAldEVYdGRhdGU6Y3JlYXRlADIwMjEt MDItMDRUMjI6MTA6NTcrMDA6MDB2ytaIAAAAJXRFWHRkYXRlOm1vZGlmeQAyMDIxLTAyLTA0VDIy OjEwOjU3KzAwOjAwB5duNAAAAABJRU5ErkJggg== X-Now-Playing: Kid Creole & The Coconuts's _I'm A Wonderful Thing, Baby_: "I'm A Wonderful Thing, Baby (Brothers In Rhythm 12" Remix)" Date: Sun, 07 Feb 2021 21:42:30 +0100 In-Reply-To: (Stefan Monnier's message of "Sun, 07 Feb 2021 15:37:28 -0500") Message-ID: <87r1lry5hl.fsf@gnus.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Report: Spam detection software, running on the system "quimby.gnus.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see @@CONTACT_ADDRESS@@ for details. Content preview: Stefan Monnier writes: >> So ... it's using the cache is only faster when we have monumentally >> long lines, since memchr is so fast? And in buffers with lines with >> normal line lengths, it's 10x slower? That sounds like [...] Content analysis details: (-2.9 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -1.0 ALL_TRUSTED Passed through trusted hosts only via SMTP -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] X-Spam-Score: 0.0 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) Stefan Monnier writes: >> So ... it's using the cache is only faster when we have monumentally >> long lines, since memchr is so fast? And in buffers with lines with >> normal line lengths, it's 10x slower? That sounds like a rather drastic >> trade-off. > > Yes, the problem is when you have pathologically-long lines (typically, > when the whole file has virtually no \n in it, so lines can reach > multi-MB lengths). Right, and in that case a cached version would definitely be faster on repeated executions. Why does display_count_lines (with no cache) exist, then? Historical reasons? -- (domestic pets only, the antidote for overdose, milk.) bloggy blog: http://lars.ingebrigtsen.no From unknown Tue Jun 17 22:28:10 2025 X-Loop: help-debbugs@gnu.org Subject: bug#22763: 25.1.50; Feature Request -- A faster method to obtain line number at position. Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 07 Feb 2021 20:51:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 22763 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: fixed To: Lars Ingebrigtsen Cc: 22763@debbugs.gnu.org, esq@lawlist.com, monnier@iro.umontreal.ca Received: via spool by 22763-submit@debbugs.gnu.org id=B22763.161273104220445 (code B ref 22763); Sun, 07 Feb 2021 20:51:02 +0000 Received: (at 22763) by debbugs.gnu.org; 7 Feb 2021 20:50:42 +0000 Received: from localhost ([127.0.0.1]:48957 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1l8r0z-0005Jh-Uy for submit@debbugs.gnu.org; Sun, 07 Feb 2021 15:50:42 -0500 Received: from eggs.gnu.org ([209.51.188.92]:33626) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1l8r0v-0005JL-R0 for 22763@debbugs.gnu.org; Sun, 07 Feb 2021 15:50:40 -0500 Received: from fencepost.gnu.org ([2001:470:142:3::e]:37374) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1l8r0p-0002MX-Rf; Sun, 07 Feb 2021 15:50:31 -0500 Received: from 84.94.185.95.cable.012.net.il ([84.94.185.95]:4760 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1l8r0c-0001tD-B5; Sun, 07 Feb 2021 15:50:31 -0500 Date: Sun, 07 Feb 2021 22:50:29 +0200 Message-Id: <83v9b3li0a.fsf@gnu.org> From: Eli Zaretskii In-Reply-To: <87r1lry5hl.fsf@gnus.org> (message from Lars Ingebrigtsen on Sun, 07 Feb 2021 21:42:30 +0100) References: <83y4aclofm.fsf@gnu.org> <878s7z532u.fsf@gnus.org> <87y2fz3lpe.fsf@gnus.org> <87h7mn22ls.fsf@gnus.org> <83eehrn408.fsf@gnu.org> <87y2fzzqxb.fsf@gnus.org> <87tuqnzqh2.fsf@gnus.org> <83blcvn1ku.fsf@gnu.org> <87czxbznly.fsf@gnus.org> <87r1lry5hl.fsf@gnus.org> X-Spam-Score: -0.7 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.7 (-) > From: Lars Ingebrigtsen > Cc: Eli Zaretskii , 22763@debbugs.gnu.org, esq@lawlist.com > Date: Sun, 07 Feb 2021 21:42:30 +0100 > > Why does display_count_lines (with no cache) exist, then? It exists to support the line-number display on the mode line. That display has its own cache, as part of the window object, so display_count_lines very rarely needs to count from the beginning of the buffer, it usually counts from the last place it stopped the previous time for the same window. This is why it has the signature that it has. From unknown Tue Jun 17 22:28:10 2025 X-Loop: help-debbugs@gnu.org Subject: bug#22763: 25.1.50; Feature Request -- A faster method to obtain line number at position. Resent-From: Lars Ingebrigtsen Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 07 Feb 2021 21:37:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 22763 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: fixed To: Eli Zaretskii Cc: 22763@debbugs.gnu.org, esq@lawlist.com, monnier@iro.umontreal.ca Received: via spool by 22763-submit@debbugs.gnu.org id=B22763.1612733793689 (code B ref 22763); Sun, 07 Feb 2021 21:37:01 +0000 Received: (at 22763) by debbugs.gnu.org; 7 Feb 2021 21:36:33 +0000 Received: from localhost ([127.0.0.1]:49089 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1l8rjN-0000B3-0Q for submit@debbugs.gnu.org; Sun, 07 Feb 2021 16:36:33 -0500 Received: from quimby.gnus.org ([95.216.78.240]:40122) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1l8rjJ-0000An-4i for 22763@debbugs.gnu.org; Sun, 07 Feb 2021 16:36:31 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnus.org; s=20200322; h=Content-Type:MIME-Version:Message-ID:In-Reply-To:Date: References:Subject:Cc:To:From:Sender:Reply-To:Content-Transfer-Encoding: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=EZlzo4Wu4AaYJYL7ItUQsafod8QUXhesalB0qkb1juc=; b=QSchBbgmMsn8+9LAJtPaN+h3pl nCJmSpzLfxQcli3JOXX7mohDfQnAH/TY/mNakuSZm2C8y3136OdqdesdLt92WMrQf/8kNvNnTuwvP nVxQp/TCr/V9ds2srksVhAbgjQ/36gcFdXAEiCbeMcZyYlXCv14Mqrl9aNxPtWEHMyRQ=; Received: from cm-84.212.202.86.getinternet.no ([84.212.202.86] helo=xo) by quimby.gnus.org with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1l8rj3-0005Ar-Ub; Sun, 07 Feb 2021 22:36:21 +0100 From: Lars Ingebrigtsen References: <83y4aclofm.fsf@gnu.org> <878s7z532u.fsf@gnus.org> <87y2fz3lpe.fsf@gnus.org> <87h7mn22ls.fsf@gnus.org> <83eehrn408.fsf@gnu.org> <87y2fzzqxb.fsf@gnus.org> <87tuqnzqh2.fsf@gnus.org> <83blcvn1ku.fsf@gnu.org> <87czxbznly.fsf@gnus.org> <87r1lry5hl.fsf@gnus.org> <83v9b3li0a.fsf@gnu.org> Face: iVBORw0KGgoAAAANSUhEUgAAADAAAAAwBAMAAAClLOS0AAAABGdBTUEAALGPC/xhBQAAACBj SFJNAAB6JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3CculE8AAAAGFBMVEVRam0xOFHNxq2k iFldZmCXGgu3ZB3///+tWyq4AAAAAWJLR0QHFmGI6wAAAAd0SU1FB+UCBxUeJnHrkPEAAAGtSURB VDjLpdRPd6IwEADw/KF7JgU9u4HeNajnSEbv+xZ6r0i+/0fozAS7uNq+7tu5BObHZCDJQwgOKZT2 gLGFKTithKyUcqKFumqJQsMgnRBOaWUKqFqwBsF6rsiKlVKqMQbqUBlTAkxgTK6d3ryOmArLX1hS McjlmFMdAyzeymtvhJIgjpjxp9jRwLLoOxpOl4zBg08VAq95oAo4jv5aIJ4i9dAx4jeE3dh9gDzh hbIYVbDW2XpqrjdK194R2JbAJsiqjSisj4Nr9rGn+J3mkuuf5rkpIwdD3yUw0uTG3INJ8b8A34bx EQz/DOfPejyGxZnW8AEs70FSvpzgdQY/DlRwYbikknRMMgZgGE8zSE1q3sHL0zRTOrsEK2cra7fH Gegr1Awdz/QlKGkEw9pNUH5UfAH5Wl3heDNVvlLWt7bezcEYfGMEPKUJuhtwNmLFcQ4yR9jFfojD dg46wTDszvt9fwcvDR+SsYe/YGVt6Afs8QfwXVPzzNsbkAS5V7XIHAEkwPVrDiJrDoH+IVv6ywRI kG8QAzS4kUUT8CbQloqDARpx3WjxgZIFPfkOxPLTQ0eiKuIAAAAldEVYdGRhdGU6Y3JlYXRlADIw MjEtMDItMDdUMjE6MzA6MzgrMDA6MDCKg84bAAAAJXRFWHRkYXRlOm1vZGlmeQAyMDIxLTAyLTA3 VDIxOjMwOjM4KzAwOjAw+952pwAAAABJRU5ErkJggg== X-Now-Playing: =?UTF-8?Q?Gar=C3=A7ons's?= _Divorce_: "French Boy" Date: Sun, 07 Feb 2021 22:36:12 +0100 In-Reply-To: <83v9b3li0a.fsf@gnu.org> (Eli Zaretskii's message of "Sun, 07 Feb 2021 22:50:29 +0200") Message-ID: <87zh0fwofn.fsf@gnus.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Report: Spam detection software, running on the system "quimby.gnus.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see @@CONTACT_ADDRESS@@ for details. Content preview: Eli Zaretskii writes: >> From: Lars Ingebrigtsen >> Cc: Eli Zaretskii , 22763@debbugs.gnu.org, esq@lawlist.com >> Date: Sun, 07 Feb 2021 21:42:30 +0100 >> >> Why does display_count_lines (wit [...] Content analysis details: (-2.9 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -1.0 ALL_TRUSTED Passed through trusted hosts only via SMTP -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] X-Spam-Score: 0.0 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) Eli Zaretskii writes: >> From: Lars Ingebrigtsen >> Cc: Eli Zaretskii , 22763@debbugs.gnu.org, esq@lawlist.com >> Date: Sun, 07 Feb 2021 21:42:30 +0100 >> >> Why does display_count_lines (with no cache) exist, then? > > It exists to support the line-number display on the mode line. That > display has its own cache, as part of the window object, so > display_count_lines very rarely needs to count from the beginning of > the buffer, it usually counts from the last place it stopped the > previous time for the same window. This is why it has the signature > that it has. But these are the signatures: ptrdiff_t find_newline (ptrdiff_t start, ptrdiff_t start_byte, ptrdiff_t end, ptrdiff_t end_byte, ptrdiff_t count, ptrdiff_t *counted, ptrdiff_t *bytepos, bool allow_quit) static ptrdiff_t display_count_lines (ptrdiff_t start_byte, ptrdiff_t limit_byte, ptrdiff_t count, ptrdiff_t *byte_pos_ptr) So they seem very similar... Anyway, here's something that just occurred to me: It's still the plan to have so-long-mode on by default, right? Which means that 'buffer-line-statistics' will be called when opening a file, which means that we know whether there are any long lines in the buffer. Could we use this info to switch between cached and non-cached action for find_newline? (I.e., just set 'cache-long-scans'.) Conversely, could we use find_newline to trigger so-long-mode? Today, so-long-mode isn't able to step into the fray when something plops a long line into the buffer (in shell-mode, for instance). If find_newline finds a long line, it could switch 'cache-long-scans' on, and also (on perhaps a different threshold) notify so-long-mode? -- (domestic pets only, the antidote for overdose, milk.) bloggy blog: http://lars.ingebrigtsen.no From unknown Tue Jun 17 22:28:10 2025 X-Loop: help-debbugs@gnu.org Subject: bug#22763: 25.1.50; Feature Request -- A faster method to obtain line number at position. Resent-From: Lars Ingebrigtsen Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 07 Feb 2021 21:54:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 22763 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: fixed To: Eli Zaretskii Cc: 22763@debbugs.gnu.org, esq@lawlist.com, monnier@iro.umontreal.ca Received: via spool by 22763-submit@debbugs.gnu.org id=B22763.16127348012215 (code B ref 22763); Sun, 07 Feb 2021 21:54:02 +0000 Received: (at 22763) by debbugs.gnu.org; 7 Feb 2021 21:53:21 +0000 Received: from localhost ([127.0.0.1]:49107 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1l8rzd-0000Zf-KO for submit@debbugs.gnu.org; Sun, 07 Feb 2021 16:53:21 -0500 Received: from quimby.gnus.org ([95.216.78.240]:40216) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1l8rzZ-0000ZP-UN for 22763@debbugs.gnu.org; Sun, 07 Feb 2021 16:53:19 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnus.org; s=20200322; h=Content-Type:MIME-Version:Message-ID:In-Reply-To:Date: References:Subject:Cc:To:From:Sender:Reply-To:Content-Transfer-Encoding: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=uaBr7Ox6iLxBH1CaC8KIxOwTCWtBrG5IbWvH32x67g0=; b=BAS2/cIuqT7sqYLA7wTXckVvUK Y51+Yjy97LcRGZ8xwBciQOiAGu2P9itaqyp1yFguffCiDYfeVc+NK+qYnvObFKQid1GYPfmsdLTDF nWbXl1Q0Sp4ydAzXxKVQGGd0pe5MhpPFPOg0GIZnF/Ruxs8Y/tsPhPn20lN4mO718ExQ=; Received: from cm-84.212.202.86.getinternet.no ([84.212.202.86] helo=xo) by quimby.gnus.org with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1l8rzC-0005Kl-PT; Sun, 07 Feb 2021 22:53:03 +0100 From: Lars Ingebrigtsen References: <83y4aclofm.fsf@gnu.org> <878s7z532u.fsf@gnus.org> <87y2fz3lpe.fsf@gnus.org> <87h7mn22ls.fsf@gnus.org> <83eehrn408.fsf@gnu.org> <87y2fzzqxb.fsf@gnus.org> <87tuqnzqh2.fsf@gnus.org> <83blcvn1ku.fsf@gnu.org> <87czxbznly.fsf@gnus.org> <834kinmzpy.fsf@gnu.org> <87zh0fy82q.fsf@gnus.org> <83y2fzlkpk.fsf@gnu.org> X-Now-Playing: =?UTF-8?Q?Gar=C3=A7ons's?= _Divorce_: "Critics" Date: Sun, 07 Feb 2021 22:52:53 +0100 In-Reply-To: <83y2fzlkpk.fsf@gnu.org> (Eli Zaretskii's message of "Sun, 07 Feb 2021 21:52:07 +0200") Message-ID: <87v9b3wnnu.fsf@gnus.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Report: Spam detection software, running on the system "quimby.gnus.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see @@CONTACT_ADDRESS@@ for details. Content preview: Eli Zaretskii writes: >> Perhaps memchr has gotten faster over the years? > > No, it was fast then as well (due to inlining, AFAIR). > > I think the main factor is the file used to benchmark this stuff. I > don't remember [...] Content analysis details: (-2.9 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -1.0 ALL_TRUSTED Passed through trusted hosts only via SMTP -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] X-Spam-Score: 0.0 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) Eli Zaretskii writes: >> Perhaps memchr has gotten faster over the years? > > No, it was fast then as well (due to inlining, AFAIR). > > I think the main factor is the file used to benchmark this stuff. I > don't remember what I used. I was curious as to how memchr is implemented these days: https://code.woboq.org/userspace/glibc/string/memchr.c.html It seems it tests one longword_ptr at a time? So that's 8 bytes on 64-bit CPUs, I think. Doesn't look like any SSE/AVX support, though. -- (domestic pets only, the antidote for overdose, milk.) bloggy blog: http://lars.ingebrigtsen.no From unknown Tue Jun 17 22:28:10 2025 X-Loop: help-debbugs@gnu.org Subject: bug#22763: 25.1.50; Feature Request -- A faster method to obtain line number at position. Resent-From: Lars Ingebrigtsen Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 07 Feb 2021 21:59:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 22763 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: fixed To: Eli Zaretskii Cc: 22763@debbugs.gnu.org, esq@lawlist.com, monnier@iro.umontreal.ca Received: via spool by 22763-submit@debbugs.gnu.org id=B22763.16127351202662 (code B ref 22763); Sun, 07 Feb 2021 21:59:01 +0000 Received: (at 22763) by debbugs.gnu.org; 7 Feb 2021 21:58:40 +0000 Received: from localhost ([127.0.0.1]:49111 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1l8s4l-0000gr-AD for submit@debbugs.gnu.org; Sun, 07 Feb 2021 16:58:40 -0500 Received: from quimby.gnus.org ([95.216.78.240]:40244) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1l8s4f-0000gY-Np for 22763@debbugs.gnu.org; Sun, 07 Feb 2021 16:58:37 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnus.org; s=20200322; h=Content-Type:MIME-Version:Message-ID:In-Reply-To:Date: References:Subject:Cc:To:From:Sender:Reply-To:Content-Transfer-Encoding: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=I7tArte4fcPzXJz21eSwvLoVwUnha94RLuYDLzdWnhE=; b=glCI7XyuDQmrvR1k2ozsiGuLPc rTsQbvyvG1/GoGiTBCsWCeD9UFOTnmBP/0XGT/Rd7HPXzCoEhLEBgzQ1sBAThUCWze2IpOftoNZnj /Tr1w+VdbBHDLiiKQPZ03Vr7NGJOLfPn1/nmHOqYT7fRUH0eq7F0o9HqOWSMLIfM36Pc=; Received: from cm-84.212.202.86.getinternet.no ([84.212.202.86] helo=xo) by quimby.gnus.org with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1l8s4M-0005Oc-Iw; Sun, 07 Feb 2021 22:58:20 +0100 From: Lars Ingebrigtsen References: <83y4aclofm.fsf@gnu.org> <878s7z532u.fsf@gnus.org> <87y2fz3lpe.fsf@gnus.org> <87h7mn22ls.fsf@gnus.org> <83eehrn408.fsf@gnu.org> <87y2fzzqxb.fsf@gnus.org> <87tuqnzqh2.fsf@gnus.org> <83blcvn1ku.fsf@gnu.org> <87czxbznly.fsf@gnus.org> <834kinmzpy.fsf@gnu.org> <87zh0fy82q.fsf@gnus.org> <83y2fzlkpk.fsf@gnu.org> <87v9b3wnnu.fsf@gnus.org> Face: iVBORw0KGgoAAAANSUhEUgAAADAAAAAwBAMAAAClLOS0AAAABGdBTUEAALGPC/xhBQAAACBj SFJNAAB6JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3CculE8AAAAGFBMVEVRam0xOFHNxq2k iFldZmCXGgu3ZB3///+tWyq4AAAAAWJLR0QHFmGI6wAAAAd0SU1FB+UCBxUeJnHrkPEAAAGtSURB VDjLpdRPd6IwEADw/KF7JgU9u4HeNajnSEbv+xZ6r0i+/0fozAS7uNq+7tu5BObHZCDJQwgOKZT2 gLGFKTithKyUcqKFumqJQsMgnRBOaWUKqFqwBsF6rsiKlVKqMQbqUBlTAkxgTK6d3ryOmArLX1hS McjlmFMdAyzeymtvhJIgjpjxp9jRwLLoOxpOl4zBg08VAq95oAo4jv5aIJ4i9dAx4jeE3dh9gDzh hbIYVbDW2XpqrjdK194R2JbAJsiqjSisj4Nr9rGn+J3mkuuf5rkpIwdD3yUw0uTG3INJ8b8A34bx EQz/DOfPejyGxZnW8AEs70FSvpzgdQY/DlRwYbikknRMMgZgGE8zSE1q3sHL0zRTOrsEK2cra7fH Gegr1Awdz/QlKGkEw9pNUH5UfAH5Wl3heDNVvlLWt7bezcEYfGMEPKUJuhtwNmLFcQ4yR9jFfojD dg46wTDszvt9fwcvDR+SsYe/YGVt6Afs8QfwXVPzzNsbkAS5V7XIHAEkwPVrDiJrDoH+IVv6ywRI kG8QAzS4kUUT8CbQloqDARpx3WjxgZIFPfkOxPLTQ0eiKuIAAAAldEVYdGRhdGU6Y3JlYXRlADIw MjEtMDItMDdUMjE6MzA6MzgrMDA6MDCKg84bAAAAJXRFWHRkYXRlOm1vZGlmeQAyMDIxLTAyLTA3 VDIxOjMwOjM4KzAwOjAw+952pwAAAABJRU5ErkJggg== X-Now-Playing: =?UTF-8?Q?Gar=C3=A7ons's?= _Divorce_: "French Boy (Reprise)" Date: Sun, 07 Feb 2021 22:58:12 +0100 In-Reply-To: <87v9b3wnnu.fsf@gnus.org> (Lars Ingebrigtsen's message of "Sun, 07 Feb 2021 22:52:53 +0100") Message-ID: <87r1lrwnez.fsf@gnus.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Report: Spam detection software, running on the system "quimby.gnus.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see @@CONTACT_ADDRESS@@ for details. Content preview: Lars Ingebrigtsen writes: > It seems it tests one longword_ptr at a time? So that's 8 bytes on > 64-bit CPUs, I think. Doesn't look like any SSE/AVX support, though. Never mind -- there are even more optimised versions using SSE2 etc, too: Content analysis details: (-2.9 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -1.0 ALL_TRUSTED Passed through trusted hosts only via SMTP -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] X-Spam-Score: 0.0 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) Lars Ingebrigtsen writes: > It seems it tests one longword_ptr at a time? So that's 8 bytes on > 64-bit CPUs, I think. Doesn't look like any SSE/AVX support, though. Never mind -- there are even more optimised versions using SSE2 etc, too: https://github.com/lattera/glibc/blob/master/sysdeps/x86_64/memchr.S I've done some further benchmarking -- with a perhaps more typical file than the ChangeLog: (with-temp-buffer (dotimes (_ 100) (insert-file-contents "~/src/emacs/trunk/lisp/printing.el") (goto-char (point-max))) (benchmark-run 10 (dotimes (i 100) (goto-char (* (/ (buffer-size) 100) i)) (line-number-at-pos (point))))) The cached version is only 5x slower than the non-cached one. -- (domestic pets only, the antidote for overdose, milk.) bloggy blog: http://lars.ingebrigtsen.no From unknown Tue Jun 17 22:28:10 2025 X-Loop: help-debbugs@gnu.org Subject: bug#22763: 25.1.50; Feature Request -- A faster method to obtain line number at position. Resent-From: Philipp Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 07 Feb 2021 22:10:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 22763 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: fixed To: Lars Ingebrigtsen Cc: 22763@debbugs.gnu.org, Eli Zaretskii , esq@lawlist.com, monnier@iro.umontreal.ca Received: via spool by 22763-submit@debbugs.gnu.org id=B22763.16127357613687 (code B ref 22763); Sun, 07 Feb 2021 22:10:02 +0000 Received: (at 22763) by debbugs.gnu.org; 7 Feb 2021 22:09:21 +0000 Received: from localhost ([127.0.0.1]:49119 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1l8sF6-0000xO-8t for submit@debbugs.gnu.org; Sun, 07 Feb 2021 17:09:21 -0500 Received: from mail-ej1-f45.google.com ([209.85.218.45]:32812) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1l8sF4-0000x8-Oe for 22763@debbugs.gnu.org; Sun, 07 Feb 2021 17:09:19 -0500 Received: by mail-ej1-f45.google.com with SMTP id sa23so21747564ejb.0 for <22763@debbugs.gnu.org>; Sun, 07 Feb 2021 14:09:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=TR+FJTS6xzpH7HV1tcU05+iw49I1VMWjvI0bj70NdD0=; b=cENx2OEaSXXp5SQfH0xNIpsik2+5/mJZrWyNzVmZ9bcgmPvSS+NaRXruN9faOQBEq5 yvieA36dUjuaaBOmu5BE7KtQ5ScvIu2IB2qOpxcQnEyMmtS1GroxM8ZCrbQgNZrK64yq X/eZENMSDLzfz08WOZI9Kt8WIUar/niWTWabRHhZv2FH0cvHnIXgy1KNMRCpDcWfK4w8 cll4E4ytHIn54GYrAftmbM5IoNcd88/MPTHIC3DhchQwfy6+SzhP+z19vZfcwB4D8m1o DPj7Cc6PyyJ1kKIoMsn9r3zqv7IW67hZX3UAmZx7f5EdteSy2P9AMIVfKINgvoeRhMY+ dtSg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=TR+FJTS6xzpH7HV1tcU05+iw49I1VMWjvI0bj70NdD0=; b=DzEoaBq2SklXsXu0/6+lI8J+RxMXW/j+OtkC7PAryi6hRjzOir8DS1b7jCZjf6YwlN 300XdK44rGcRoZEKl8gBqXuPklFw7XlVtRkGqI1WiTMHsygaZQ1iCgpxYqrBFTu/vPvi qMPD6lA87z7KOvPwW5UduaB5Q9bV56A2PadwGxBelkAKOJrUzgXyjNMy+BQqmKzh/Kn7 bG7CDcb6Iw2uA4nFXns18n11nARYqtEThTr6AOjqrBic/ruz+YNZPeg3P3L45l13xlYI BuERzyvD4LY4V+UBtouscwPEwraRQahr/8XiahDNWDRKwGM0+XKacC8uExTCnhxRyiwH k6vA== X-Gm-Message-State: AOAM531Eayb/z4GrL0X/MUOzYjhD01hvfV+9EI2N89/e8jgQ1bLHbj6w QpPVwVZRcEcmPdn7Tx6QIAc= X-Google-Smtp-Source: ABdhPJylqCD4R4ZkfrdA2X7ZawB/wFkaNe3LNYenwjwjMfEYJ6Q0vsbH2uABCGhyrwDj9pK9r2Z1OA== X-Received: by 2002:a17:906:a295:: with SMTP id i21mr14410860ejz.334.1612735752673; Sun, 07 Feb 2021 14:09:12 -0800 (PST) Received: from philipps-mbp.fritz.box ([46.128.208.19]) by smtp.gmail.com with ESMTPSA id n12sm2798896eja.46.2021.02.07.14.09.11 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sun, 07 Feb 2021 14:09:12 -0800 (PST) Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 14.0 \(3654.60.0.2.21\)) From: Philipp In-Reply-To: <87v9b3wnnu.fsf@gnus.org> Date: Sun, 7 Feb 2021 23:09:11 +0100 Content-Transfer-Encoding: quoted-printable Message-Id: <5E1AB7BA-7420-4D67-8A73-EC7E1D67C5A3@gmail.com> References: <83y4aclofm.fsf@gnu.org> <878s7z532u.fsf@gnus.org> <87y2fz3lpe.fsf@gnus.org> <87h7mn22ls.fsf@gnus.org> <83eehrn408.fsf@gnu.org> <87y2fzzqxb.fsf@gnus.org> <87tuqnzqh2.fsf@gnus.org> <83blcvn1ku.fsf@gnu.org> <87czxbznly.fsf@gnus.org> <834kinmzpy.fsf@gnu.org> <87zh0fy82q.fsf@gnus.org> <83y2fzlkpk.fsf@gnu.org> <87v9b3wnnu.fsf@gnus.org> X-Mailer: Apple Mail (2.3654.60.0.2.21) X-Spam-Score: 0.2 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.8 (/) > Am 07.02.2021 um 22:52 schrieb Lars Ingebrigtsen : >=20 > Eli Zaretskii writes: >=20 >>> Perhaps memchr has gotten faster over the years? >>=20 >> No, it was fast then as well (due to inlining, AFAIR). >>=20 >> I think the main factor is the file used to benchmark this stuff. I >> don't remember what I used. >=20 > I was curious as to how memchr is implemented these days: >=20 > https://code.woboq.org/userspace/glibc/string/memchr.c.html >=20 > It seems it tests one longword_ptr at a time? So that's 8 bytes on > 64-bit CPUs, I think. Doesn't look like any SSE/AVX support, though. I think that=E2=80=99s only the unoptimized generic version, there are = architecture-specific versions like = https://sourceware.org/git/?p=3Dglibc.git;a=3Dblob;f=3Dsysdeps/x86_64/memc= hr.S;h=3Dbeff2708de6a1e40de4141f94ff6fe763f041164;hb=3DHEAD.= From unknown Tue Jun 17 22:28:10 2025 X-Loop: help-debbugs@gnu.org Subject: bug#22763: 25.1.50; Feature Request -- A faster method to obtain line number at position. Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 08 Feb 2021 03:35:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 22763 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: fixed To: Lars Ingebrigtsen Cc: 22763@debbugs.gnu.org, esq@lawlist.com, monnier@iro.umontreal.ca Received: via spool by 22763-submit@debbugs.gnu.org id=B22763.1612755269818 (code B ref 22763); Mon, 08 Feb 2021 03:35:02 +0000 Received: (at 22763) by debbugs.gnu.org; 8 Feb 2021 03:34:29 +0000 Received: from localhost ([127.0.0.1]:49294 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1l8xJl-0000D7-79 for submit@debbugs.gnu.org; Sun, 07 Feb 2021 22:34:29 -0500 Received: from eggs.gnu.org ([209.51.188.92]:47558) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1l8xJj-0000Ct-3V for 22763@debbugs.gnu.org; Sun, 07 Feb 2021 22:34:28 -0500 Received: from fencepost.gnu.org ([2001:470:142:3::e]:44581) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1l8xJd-0006Cg-2M; Sun, 07 Feb 2021 22:34:21 -0500 Received: from 84.94.185.95.cable.012.net.il ([84.94.185.95]:1722 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1l8xJc-0001JS-Ea; Sun, 07 Feb 2021 22:34:20 -0500 Date: Mon, 08 Feb 2021 05:34:33 +0200 Message-Id: <83sg67kzau.fsf@gnu.org> From: Eli Zaretskii In-Reply-To: <87r1lrwnez.fsf@gnus.org> (message from Lars Ingebrigtsen on Sun, 07 Feb 2021 22:58:12 +0100) References: <83y4aclofm.fsf@gnu.org> <878s7z532u.fsf@gnus.org> <87y2fz3lpe.fsf@gnus.org> <87h7mn22ls.fsf@gnus.org> <83eehrn408.fsf@gnu.org> <87y2fzzqxb.fsf@gnus.org> <87tuqnzqh2.fsf@gnus.org> <83blcvn1ku.fsf@gnu.org> <87czxbznly.fsf@gnus.org> <834kinmzpy.fsf@gnu.org> <87zh0fy82q.fsf@gnus.org> <83y2fzlkpk.fsf@gnu.org> <87v9b3wnnu.fsf@gnus.org> <87r1lrwnez.fsf@gnus.org> X-Spam-Score: -0.7 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.7 (-) > From: Lars Ingebrigtsen > Cc: 22763@debbugs.gnu.org, esq@lawlist.com, monnier@iro.umontreal.ca > Date: Sun, 07 Feb 2021 22:58:12 +0100 > > Never mind -- there are even more optimised versions using SSE2 etc, > too: > > https://github.com/lattera/glibc/blob/master/sysdeps/x86_64/memchr.S You need to look at the code emitted by GCC under -O2. glibc is not necessarily relevant here. From unknown Tue Jun 17 22:28:10 2025 X-Loop: help-debbugs@gnu.org Subject: bug#22763: 25.1.50; Feature Request -- A faster method to obtain line number at position. Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 08 Feb 2021 15:05:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 22763 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: fixed To: Lars Ingebrigtsen Cc: 22763@debbugs.gnu.org, esq@lawlist.com, monnier@iro.umontreal.ca Received: via spool by 22763-submit@debbugs.gnu.org id=B22763.16127966986033 (code B ref 22763); Mon, 08 Feb 2021 15:05:02 +0000 Received: (at 22763) by debbugs.gnu.org; 8 Feb 2021 15:04:58 +0000 Received: from localhost ([127.0.0.1]:51665 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1l985y-0001ZF-Fv for submit@debbugs.gnu.org; Mon, 08 Feb 2021 10:04:58 -0500 Received: from eggs.gnu.org ([209.51.188.92]:47154) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1l985v-0001Z2-9r for 22763@debbugs.gnu.org; Mon, 08 Feb 2021 10:04:57 -0500 Received: from fencepost.gnu.org ([2001:470:142:3::e]:51511) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1l985p-0003jN-F6; Mon, 08 Feb 2021 10:04:49 -0500 Received: from 84.94.185.95.cable.012.net.il ([84.94.185.95]:4342 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1l985j-0008Q8-UJ; Mon, 08 Feb 2021 10:04:45 -0500 Date: Mon, 08 Feb 2021 17:04:58 +0200 Message-Id: <83pn1alhwl.fsf@gnu.org> From: Eli Zaretskii In-Reply-To: <87zh0fwofn.fsf@gnus.org> (message from Lars Ingebrigtsen on Sun, 07 Feb 2021 22:36:12 +0100) References: <83y4aclofm.fsf@gnu.org> <878s7z532u.fsf@gnus.org> <87y2fz3lpe.fsf@gnus.org> <87h7mn22ls.fsf@gnus.org> <83eehrn408.fsf@gnu.org> <87y2fzzqxb.fsf@gnus.org> <87tuqnzqh2.fsf@gnus.org> <83blcvn1ku.fsf@gnu.org> <87czxbznly.fsf@gnus.org> <87r1lry5hl.fsf@gnus.org> <83v9b3li0a.fsf@gnu.org> <87zh0fwofn.fsf@gnus.org> X-Spam-Score: -0.7 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.7 (-) > From: Lars Ingebrigtsen > Cc: monnier@iro.umontreal.ca, 22763@debbugs.gnu.org, esq@lawlist.com > Date: Sun, 07 Feb 2021 22:36:12 +0100 > > > It exists to support the line-number display on the mode line. That > > display has its own cache, as part of the window object, so > > display_count_lines very rarely needs to count from the beginning of > > the buffer, it usually counts from the last place it stopped the > > previous time for the same window. This is why it has the signature > > that it has. > > But these are the signatures: > > ptrdiff_t > find_newline (ptrdiff_t start, ptrdiff_t start_byte, ptrdiff_t end, > ptrdiff_t end_byte, ptrdiff_t count, ptrdiff_t *counted, > ptrdiff_t *bytepos, bool allow_quit) > > > static ptrdiff_t > display_count_lines (ptrdiff_t start_byte, > ptrdiff_t limit_byte, ptrdiff_t count, > ptrdiff_t *byte_pos_ptr) > > So they seem very similar... I was trying to explain why display_count_lines accepts arguments that may seem unnecessary at first sight if the job is to just count the lines. > Anyway, here's something that just occurred to me: It's still the plan > to have so-long-mode on by default, right? Which means that > 'buffer-line-statistics' will be called when opening a file, which means > that we know whether there are any long lines in the buffer. > > Could we use this info to switch between cached and non-cached action > for find_newline? (I.e., just set 'cache-long-scans'.) It isn't as easy as it may sound, because cache-long-scans also affects another cache, the one used by bidi.c. We need to be able to turn them on and off separately to be able to support what you suggest. > Conversely, could we use find_newline to trigger so-long-mode? Today, > so-long-mode isn't able to step into the fray when something plops a > long line into the buffer (in shell-mode, for instance). If > find_newline finds a long line, it could switch 'cache-long-scans' on, > and also (on perhaps a different threshold) notify so-long-mode? We already detect overlong lines: that's when the line number on the mode line becomes "??". We just need to use that as trigger for so-long-mode, if we want it to turn on automatically. Also, we need to consider whether the same threshold as the one we use for the mode-line display of line numbers is suitable for so-long-mode, or we need two separate thresholds. From unknown Tue Jun 17 22:28:10 2025 X-Loop: help-debbugs@gnu.org Subject: bug#22763: 25.1.50; Feature Request -- A faster method to obtain line number at position. In-Reply-To: Resent-From: Katsumi Yamaoka Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 09 Feb 2021 02:18:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 22763 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: fixed To: 22763@debbugs.gnu.org Cc: larsi@gnus.org, esq@lawlist.com, eliz@gnu.org, monnier@iro.umontreal.ca Received: via spool by 22763-submit@debbugs.gnu.org id=B22763.16128370763610 (code B ref 22763); Tue, 09 Feb 2021 02:18:02 +0000 Received: (at 22763) by debbugs.gnu.org; 9 Feb 2021 02:17:56 +0000 Received: from localhost ([127.0.0.1]:52252 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1l9IbD-0000wA-Pe for submit@debbugs.gnu.org; Mon, 08 Feb 2021 21:17:55 -0500 Received: from fossa.birch.relay.mailchannels.net ([23.83.209.62]:64484) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1l9IbA-0000vy-4m for 22763@debbugs.gnu.org; Mon, 08 Feb 2021 21:17:54 -0500 X-Sender-Id: tih5qno0ow|x-authuser|yamaoka@cloud1.hostforweb.net Received: from relay.mailchannels.net (localhost [127.0.0.1]) by relay.mailchannels.net (Postfix) with ESMTP id 5C4EE642FC2; Tue, 9 Feb 2021 02:17:50 +0000 (UTC) Received: from cloud1.hostforweb.net (100-98-118-109.trex.outbound.svc.cluster.local [100.98.118.109]) (Authenticated sender: tih5qno0ow) by relay.mailchannels.net (Postfix) with ESMTPA id 7147D642EBD; Tue, 9 Feb 2021 02:17:49 +0000 (UTC) X-Sender-Id: tih5qno0ow|x-authuser|yamaoka@cloud1.hostforweb.net Received: from cloud1.hostforweb.net (cloud1.hostforweb.net [154.16.119.57]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384) by 100.98.118.109 (trex/6.0.2); Tue, 09 Feb 2021 02:17:50 +0000 X-MC-Relay: Neutral X-MailChannels-SenderId: tih5qno0ow|x-authuser|yamaoka@cloud1.hostforweb.net X-MailChannels-Auth-Id: tih5qno0ow X-Celery-Abiding: 2054820f67735f84_1612837070080_784162413 X-MC-Loop-Signature: 1612837070080:889645830 X-MC-Ingress-Time: 1612837070080 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=jpl.org; s=default; h=Content-Transfer-Encoding:Content-Type:MIME-Version:References: Subject:Cc:To:From:Message-ID:Date:Sender:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:In-Reply-To:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=qPiUzaO7PIcRELi5gQ5YdEFNVkQIkN+oSmyJ8lARIvw=; b=Nkl6Xyr0Fr872+ayhoI0D8fs4V CM2qUopDx68slDz4PwCqxqRys8w7J0ZaOSYk7iU1MtA24Xh078w5tbMaBsCjwSFl9xwv4nOc+wrIT S73+c+ZzGigtdyV2V5/APoIsWxErc/I9XMPBAHXyPOMGXHbv0Z5m6M2KmRnZXyvQ/vdkIX5trutRg 0IfifozWljcyLzZ07/FwmjfNuB3EQVDdeKQuTQZkKP0g7H5fqJrBYvg12HYiyVq2HG9J3NXVyKMdN FbzbxTmovST+HNPXCEDml8QXCJrFdXlsrni1uggC/LyaFDQICSoDz/eeOZjsijsqqK7DMhGNIV7Ud 91FQVNPg==; Received: from 113x33x36x204.ap113.ftth.ucom.ne.jp ([113.33.36.204]:52066 helo=localhost) by cloud1.hostforweb.net with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.93) (envelope-from ) id 1l9Ib6-0004Qo-47; Mon, 08 Feb 2021 21:17:48 -0500 Date: Tue, 09 Feb 2021 11:17:42 +0900 Message-ID: From: Katsumi Yamaoka References: <83y4aclofm.fsf@gnu.org> <878s7z532u.fsf@gnus.org> <87y2fz3lpe.fsf@gnus.org> <87h7mn22ls.fsf@gnus.org> <83eehrn408.fsf@gnu.org> <87y2fzzqxb.fsf@gnus.org> <87tuqnzqh2.fsf@gnus.org> <83blcvn1ku.fsf@gnu.org> <87czxbznly.fsf@gnus.org> <87r1lry5hl.fsf@gnus.org> <83v9b3li0a.fsf@gnu.org> <87zh0fwofn.fsf@gnus.org> <83pn1alhwl.fsf@gnu.org> Organization: Emacsen advocacy group X-Face: #kKnN,xUnmKia.'[pp`; Omh}odZK)?7wQSl"4o04=EixTF+V[""w~iNbM9ZL+.b*_CxUmFk B#Fu[*?MZZH@IkN:!"\w%I_zt>[$nm7nQosZ<3eu; B:$Q_:p!',P.c0-_Cy[dz4oIpw0ESA^D*1Lw= L&i*6&( User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (x86_64-pc-cygwin) Cancel-Lock: sha1:tzMUCChECRj3jXV4E26YOSWX9qg= MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-AuthUser: yamaoka@cloud1.hostforweb.net X-Spam-Score: 0.0 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) Hi, `gnus-cite-parse' got to fail on Gnus articles containing non-ASCII text. It is because `count-lines', that uses `line-number-at-pos' now, fails to count text lines correctly as follows: (with-temp-buffer (insert "=E3=81=82\n=E3=81=84\n=E3=81=86\n=E3=81=88\n=E3=81=8A\n") (count-lines (point) (point))) =3D> 3 (save-window-excursion (view-hello-file) (goto-char (point-max)) (count-lines (point) (point))) =3D> 41 Thanks. From unknown Tue Jun 17 22:28:10 2025 X-Loop: help-debbugs@gnu.org Subject: bug#22763: 25.1.50; Feature Request -- A faster method to obtain line number at position. Resent-From: Lars Ingebrigtsen Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 09 Feb 2021 07:15:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 22763 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: fixed To: Katsumi Yamaoka Cc: 22763@debbugs.gnu.org, eliz@gnu.org, esq@lawlist.com, monnier@iro.umontreal.ca Received: via spool by 22763-submit@debbugs.gnu.org id=B22763.161285485230873 (code B ref 22763); Tue, 09 Feb 2021 07:15:01 +0000 Received: (at 22763) by debbugs.gnu.org; 9 Feb 2021 07:14:12 +0000 Received: from localhost ([127.0.0.1]:52421 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1l9NDv-00081s-Mm for submit@debbugs.gnu.org; Tue, 09 Feb 2021 02:14:11 -0500 Received: from quimby.gnus.org ([95.216.78.240]:55412) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1l9NDq-00081E-DY for 22763@debbugs.gnu.org; Tue, 09 Feb 2021 02:14:10 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnus.org; s=20200322; h=Content-Transfer-Encoding:Content-Type:MIME-Version:Message-ID :In-Reply-To:Date:References:Subject:Cc:To:From:Sender:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=T2QkvPjE/kX1nfHExOfvrm7UL2V+WFRxARexfb/EePg=; b=g9koSSPpshH44oDqWMY3JqzVhS TpQcBAM35LMQ+jc7rQCWPhlFfYkaJKsrzp27RvTtX5A4RTu37OkvONpy2lCwgNae7c/2bx9tQdQjb r6lrJMb0AxE3sEj06RurSOQqrJEw9Fqiz04EQZhyxGft4s5H5DDNiMdpoawunGzZggys=; Received: from cm-84.212.202.86.getinternet.no ([84.212.202.86] helo=xo) by quimby.gnus.org with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1l9NDQ-0008Bm-Kl; Tue, 09 Feb 2021 08:13:44 +0100 From: Lars Ingebrigtsen References: <83y4aclofm.fsf@gnu.org> <878s7z532u.fsf@gnus.org> <87y2fz3lpe.fsf@gnus.org> <87h7mn22ls.fsf@gnus.org> <83eehrn408.fsf@gnu.org> <87y2fzzqxb.fsf@gnus.org> <87tuqnzqh2.fsf@gnus.org> <83blcvn1ku.fsf@gnu.org> <87czxbznly.fsf@gnus.org> <87r1lry5hl.fsf@gnus.org> <83v9b3li0a.fsf@gnu.org> <87zh0fwofn.fsf@gnus.org> <83pn1alhwl.fsf@gnu.org> Face: iVBORw0KGgoAAAANSUhEUgAAADAAAAAwBAMAAAClLOS0AAAABGdBTUEAALGPC/xhBQAAACBj SFJNAAB6JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3CculE8AAAAGFBMVEXs1Jr967DQvo6s kVWUbjdeQC9VOSz///9RMRGeAAAAAWJLR0QHFmGI6wAAAAd0SU1FB+UCCQcMFD61sY8AAAGKSURB VDjLlZNdbsIwDMdd4AApvUBp0Z6hzfaMGsPzpNU9wCC5/xFmJ03aaCBtllBj//A/H7ahKJ8bvATl H0HxChxyoJLf5aCKQJkc6Aj2eF6DCiOojFmDo47/22l9WsAek4DWOGcL2CEOsxJiXENwZ+UNtEyK lVTSKqMWBMcMEVRrsEVcDozYQFtrkGdTsqUKV9+iIXbHcPOjT1FN0105xoAQ0jGNRrqONOKVkIg8 gCN75GikYPKFbmiRY7PFxUSw+NNEZOVjJeDBxMA650hi5IRa8AtnJzcxkZ+NQJzZbACc7x7gMhvd ZN39Y+zrX+DmdP1m+Qp5eOxvtii33CvwCLEba/TosDUn/7AKPv2Gd87/llLGWpbwZfv3x6E7lfy6 SqdalqBqrmAsxqowMgYVDnBIhb0s7eMffWmTIgERmF1JOYcuUb6vEqiiluyxBiqBfA/ROicQj1+E tl56t1TtquFMNmqcL/0l4JIBzu+bru+LNHUzYKVGjJ88H87U7GnQA9jkwQU8sf+DH89Hr7OqjPml AAAAJXRFWHRkYXRlOmNyZWF0ZQAyMDIxLTAyLTA5VDA3OjEyOjIwKzAwOjAwSFYExQAAACV0RVh0 ZGF0ZTptb2RpZnkAMjAyMS0wMi0wOVQwNzoxMjoyMCswMDowMDkLvHkAAAAASUVORK5CYII= X-Now-Playing: Masada's _Alef_: "Idalah-abal" Date: Tue, 09 Feb 2021 08:13:39 +0100 In-Reply-To: (Katsumi Yamaoka's message of "Tue, 09 Feb 2021 11:17:42 +0900") Message-ID: <87im71lnmk.fsf@gnus.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Report: Spam detection software, running on the system "quimby.gnus.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see @@CONTACT_ADDRESS@@ for details. Content preview: Katsumi Yamaoka writes: > `gnus-cite-parse' got to fail on Gnus articles containing non-ASCII > text. It is because `count-lines', that uses `line-number-at-pos' > now, fails to count text lines correctly as follows: > > (wi [...] Content analysis details: (-2.9 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -1.0 ALL_TRUSTED Passed through trusted hosts only via SMTP -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] X-Spam-Score: 0.0 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) Katsumi Yamaoka writes: > `gnus-cite-parse' got to fail on Gnus articles containing non-ASCII > text. It is because `count-lines', that uses `line-number-at-pos' > now, fails to count text lines correctly as follows: > > (with-temp-buffer > (insert "=E3=81=82\n=E3=81=84\n=E3=81=86\n=E3=81=88\n=E3=81=8A\n") > (count-lines (point) (point))) > =3D> 3 Ooops. Looks like I fumbled the char/byte thing in 56e76f0eb. This should now be fixed. --=20 (domestic pets only, the antidote for overdose, milk.) bloggy blog: http://lars.ingebrigtsen.no From debbugs-submit-bounces@debbugs.gnu.org Wed May 19 19:52:06 2021 Received: (at control) by debbugs.gnu.org; 19 May 2021 23:52:06 +0000 Received: from localhost ([127.0.0.1]:60942 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ljVyw-0003Ru-Cx for submit@debbugs.gnu.org; Wed, 19 May 2021 19:52:06 -0400 Received: from mail4.protonmail.ch ([185.70.40.27]:45974) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ljVwh-0003Mz-1e for control@debbugs.gnu.org; Wed, 19 May 2021 19:49:47 -0400 Date: Wed, 19 May 2021 23:49:32 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=protonmail.ch; s=protonmail; t=1621468181; bh=y7fHAennQWhUqm3DUT5MkoCr1++qEAn7oE0vop+GdJ0=; h=Date:To:From:Reply-To:Subject:From; b=O1mpWLgYckm2jpI/q0sEUHg5aOWDPdPf+57FurzDmPdD3ntCqcXqqHFNfdqwPtscU nOkgqii0kRNltvgyjwaGJsxTEhq39KfHjomToEeF4oAQ8WDBwnEg+0B723bJkhP0Ec GvXoN1rRnXQfIY3X82JoTfK3erXLt6IR9gGUYFkU= To: "control@debbugs.gnu.org" From: Blevy Subject: unarchive 22763 Message-ID: <1uD9oN7jQeHGIVJvv_oZHcFopsYZZli7L1yN29Oz7BTkhcsUGNG48e5oQNd9HQEIcvWOvtV2mT4-vhm5FKH_A4fZpWrwKRMYdfdRwudP50Y=@protonmail.ch> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-1.2 required=10.0 tests=ALL_TRUSTED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM shortcircuit=no autolearn=disabled version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on mailout.protonmail.ch X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: control X-Mailman-Approved-At: Wed, 19 May 2021 19:52:06 -0400 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: Blevy Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) unarchive 22763 From unknown Tue Jun 17 22:28:10 2025 X-Loop: help-debbugs@gnu.org Subject: bug#22763: 25.1.50; Feature Request -- A faster method to obtain line number at position. References: In-Reply-To: Resent-From: Ben Levy Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 19 May 2021 23:56:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 22763 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: fixed To: "22763@debbugs.gnu.org" <22763@debbugs.gnu.org> Reply-To: Ben Levy Received: via spool by 22763-submit@debbugs.gnu.org id=B22763.162146854613625 (code B ref 22763); Wed, 19 May 2021 23:56:01 +0000 Received: (at 22763) by debbugs.gnu.org; 19 May 2021 23:55:46 +0000 Received: from localhost ([127.0.0.1]:60955 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ljW2U-0003Xh-Ki for submit@debbugs.gnu.org; Wed, 19 May 2021 19:55:46 -0400 Received: from mail-40140.protonmail.ch ([185.70.40.140]:35581) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ljW2S-0003XS-Tp for 22763@debbugs.gnu.org; Wed, 19 May 2021 19:55:45 -0400 Date: Wed, 19 May 2021 23:55:27 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=protonmail.com; s=protonmail; t=1621468538; bh=JoGVw7DdBzYzXLd5N5RFDzXwsn+br155PWF9mqxuvBg=; h=Date:To:From:Reply-To:Subject:From; b=KsrWisNTQgDTAzV+ZyxczEF1S55u1a4VZymxYW/Qj8e0pKlKru/4w3rxYBtAnhJRd RGip5FVqgZ79nac6EhJZkPq8vouQuewxOeGh+1JH2vLMz4SbSXgSwOVS/TrittZlDA Y4/IAP0S9r2Hy/4anArBgdwuevFC4mXStPX3WavE= From: Ben Levy Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-1.2 required=10.0 tests=ALL_TRUSTED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM shortcircuit=no autolearn=disabled version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on mailout.protonmail.ch X-Spam-Score: 0.0 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) For this section in the line-number-at-pos code: /* Check that POSITION is n the visible range of the buffer. */ if (pos < BEGV || pos > ZV) args_out_of_range (make_int (start), make_int (ZV)); Shouldn't the lower bound condition be pos < start instead of pos < BEGV? From unknown Tue Jun 17 22:28:10 2025 X-Loop: help-debbugs@gnu.org Subject: bug#22763: 25.1.50; Feature Request -- A faster method to obtain line number at position. Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 20 May 2021 06:46:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 22763 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: fixed To: Ben Levy Cc: 22763@debbugs.gnu.org Received: via spool by 22763-submit@debbugs.gnu.org id=B22763.16214931574221 (code B ref 22763); Thu, 20 May 2021 06:46:02 +0000 Received: (at 22763) by debbugs.gnu.org; 20 May 2021 06:45:57 +0000 Received: from localhost ([127.0.0.1]:32987 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ljcRR-000161-H0 for submit@debbugs.gnu.org; Thu, 20 May 2021 02:45:57 -0400 Received: from eggs.gnu.org ([209.51.188.92]:56110) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ljcRP-00015m-O8 for 22763@debbugs.gnu.org; Thu, 20 May 2021 02:45:56 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]:49582) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ljcRJ-0005dQ-FU; Thu, 20 May 2021 02:45:49 -0400 Received: from 84.94.185.95.cable.012.net.il ([84.94.185.95]:1711 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ljcRJ-0000kl-15; Thu, 20 May 2021 02:45:49 -0400 Date: Thu, 20 May 2021 09:45:57 +0300 Message-Id: <83cztlq4wq.fsf@gnu.org> From: Eli Zaretskii In-Reply-To: (bug-gnu-emacs@gnu.org) References: X-Spam-Score: -2.3 (--) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) > Date: Wed, 19 May 2021 23:55:27 +0000 > From: Ben Levy via "Bug reports for GNU Emacs, > the Swiss army knife of text editors" > > For this section in the line-number-at-pos code: > > /* Check that POSITION is n the visible range of the buffer. */ > if (pos < BEGV || pos > ZV) > args_out_of_range (make_int (start), make_int (ZV)); > > Shouldn't the lower bound condition be pos < start instead of pos < BEGV? No, because 'start' is the _byte_ position, whereas 'pos' is the character position. So if 'start's value is BEGV_BYTE, the test above already made sure 'pos' is correct, because it makes the equivalent text of the character position. And if 'start' is BEG_BYTE, then 'pos' cannot possibly be less than the beginning of the buffer, because 'pos >= BEGV_BYTE' is a more strict condition. From unknown Tue Jun 17 22:28:10 2025 X-Loop: help-debbugs@gnu.org Subject: bug#22763: 25.1.50; Feature Request -- A faster method to obtain line number at position. Resent-From: Andreas Schwab Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 20 May 2021 07:28:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 22763 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: fixed To: Eli Zaretskii Cc: Ben Levy , 22763@debbugs.gnu.org Received: via spool by 22763-submit@debbugs.gnu.org id=B22763.16214956758341 (code B ref 22763); Thu, 20 May 2021 07:28:02 +0000 Received: (at 22763) by debbugs.gnu.org; 20 May 2021 07:27:55 +0000 Received: from localhost ([127.0.0.1]:33019 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ljd62-0002AS-Pe for submit@debbugs.gnu.org; Thu, 20 May 2021 03:27:55 -0400 Received: from mail-out.m-online.net ([212.18.0.10]:33488) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ljd5l-00029w-V0 for 22763@debbugs.gnu.org; Thu, 20 May 2021 03:27:53 -0400 Received: from frontend01.mail.m-online.net (unknown [192.168.8.182]) by mail-out.m-online.net (Postfix) with ESMTP id 4Fm1Xm3QhBz1s6R3; Thu, 20 May 2021 09:27:36 +0200 (CEST) Received: from localhost (dynscan1.mnet-online.de [192.168.6.70]) by mail.m-online.net (Postfix) with ESMTP id 4Fm1Xm0lhTz1qsZB; Thu, 20 May 2021 09:27:36 +0200 (CEST) X-Virus-Scanned: amavisd-new at mnet-online.de Received: from mail.mnet-online.de ([192.168.8.182]) by localhost (dynscan1.mail.m-online.net [192.168.6.70]) (amavisd-new, port 10024) with ESMTP id KaE9BtmW1stF; Thu, 20 May 2021 09:27:35 +0200 (CEST) X-Auth-Info: 7+oOtlFYjpZrEkQ7hbMmvcZtjcZaS5mQr+LksWMXRQ5VAup9qb1VRVtChqPUG+E7 Received: from igel.home (ppp-46-244-177-18.dynamic.mnet-online.de [46.244.177.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.mnet-online.de (Postfix) with ESMTPSA; Thu, 20 May 2021 09:27:35 +0200 (CEST) Received: by igel.home (Postfix, from userid 1000) id 90B6A2C35F1; Thu, 20 May 2021 09:27:34 +0200 (CEST) From: Andreas Schwab References: <83cztlq4wq.fsf@gnu.org> X-Yow: YOW!! I am having FUN!! Date: Thu, 20 May 2021 09:27:34 +0200 In-Reply-To: <83cztlq4wq.fsf@gnu.org> (Eli Zaretskii's message of "Thu, 20 May 2021 09:45:57 +0300") Message-ID: <87sg2hyie1.fsf@igel.home> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: 0.3 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.4 (-) On Mai 20 2021, Eli Zaretskii wrote: >> Date: Wed, 19 May 2021 23:55:27 +0000 >> From: Ben Levy via "Bug reports for GNU Emacs, >> the Swiss army knife of text editors" >> >> For this section in the line-number-at-pos code: >> >> /* Check that POSITION is n the visible range of the buffer. */ >> if (pos < BEGV || pos > ZV) >> args_out_of_range (make_int (start), make_int (ZV)); >> >> Shouldn't the lower bound condition be pos < start instead of pos < BEGV? > > No, because 'start' is the _byte_ position, But it should not be passed to args_out_of_range then. Andreas. -- Andreas Schwab, schwab@linux-m68k.org GPG Key fingerprint = 7578 EB47 D4E5 4D69 2510 2552 DF73 E780 A9DA AEC1 "And now for something completely different." From unknown Tue Jun 17 22:28:10 2025 X-Loop: help-debbugs@gnu.org Subject: bug#22763: 25.1.50; Feature Request -- A faster method to obtain line number at position. Resent-From: Ben Levy Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 20 May 2021 07:36:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 22763 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: fixed To: "22763@debbugs.gnu.org" <22763@debbugs.gnu.org> Reply-To: Ben Levy Received: via spool by 22763-submit@debbugs.gnu.org id=B22763.16214961359234 (code B ref 22763); Thu, 20 May 2021 07:36:01 +0000 Received: (at 22763) by debbugs.gnu.org; 20 May 2021 07:35:35 +0000 Received: from localhost ([127.0.0.1]:33024 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ljdDS-0002Os-PN for submit@debbugs.gnu.org; Thu, 20 May 2021 03:35:34 -0400 Received: from mail-40140.protonmail.ch ([185.70.40.140]:17192) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ljdDQ-0002Oc-Rr for 22763@debbugs.gnu.org; Thu, 20 May 2021 03:35:34 -0400 Date: Thu, 20 May 2021 07:35:21 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=protonmail.com; s=protonmail; t=1621496125; bh=AD3B5COpZidfNwjrPFnyQ41I0nVEQk5OSuDWr3zf8S4=; h=Date:To:From:Reply-To:Subject:In-Reply-To:References:From; b=lTcN1A+3+uiG34/8qEe26BRzNH2EQcA/h0b7stZ1woJKe4WOounWI8K4DpeRLvxrF x8p74OeZH67q0qO//3JIPhRoAbrVK3q6Q4Si99HkGnsCUrz31x9AWxObCvKfBbc8Sl frIMAb3J6HX1pTimpz9bNboE/3BSXex4lhTl1BO0= From: Ben Levy Message-ID: <5vjNVOqvf9dNS_C5IpDYnu5V0nwdAkY0R5doUtx_Y4DgskVITLuZm09swlKj7PRY9g47nwei35U-4fRO_e5Tw7VrAK7RynVKHiY3kes_FOw=@protonmail.com> In-Reply-To: <87sg2hyie1.fsf@igel.home> References: <83cztlq4wq.fsf@gnu.org> <87sg2hyie1.fsf@igel.home> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-1.2 required=10.0 tests=ALL_TRUSTED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM shortcircuit=no autolearn=disabled version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on mailout.protonmail.ch X-Spam-Score: 0.0 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) > No, because 'start' is the byte position. Oh, I was confused, sorry. In that case, I think the issue I'm having is that it still compares to BEGV even when absolute is non-nil. I think it should compare to BEG instead. > But it should not be passed to args_out_of_range then. Also this, and I think the comment has a typo ("n" should be "in"?). Thanks. From unknown Tue Jun 17 22:28:10 2025 X-Loop: help-debbugs@gnu.org Subject: bug#22763: 25.1.50; Feature Request -- A faster method to obtain line number at position. Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 20 May 2021 09:04:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 22763 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: fixed To: Andreas Schwab Cc: blevy@protonmail.com, 22763@debbugs.gnu.org Received: via spool by 22763-submit@debbugs.gnu.org id=B22763.162150139418591 (code B ref 22763); Thu, 20 May 2021 09:04:02 +0000 Received: (at 22763) by debbugs.gnu.org; 20 May 2021 09:03:14 +0000 Received: from localhost ([127.0.0.1]:33083 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ljeaH-0004pn-MF for submit@debbugs.gnu.org; Thu, 20 May 2021 05:03:13 -0400 Received: from eggs.gnu.org ([209.51.188.92]:40296) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ljeaF-0004pX-Mh for 22763@debbugs.gnu.org; Thu, 20 May 2021 05:03:12 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]:52632) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ljeaA-00032q-1W; Thu, 20 May 2021 05:03:06 -0400 Received: from 84.94.185.95.cable.012.net.il ([84.94.185.95]:2593 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ljea8-0002p8-Km; Thu, 20 May 2021 05:03:05 -0400 Date: Thu, 20 May 2021 12:03:12 +0300 Message-Id: <837djtpyjz.fsf@gnu.org> From: Eli Zaretskii In-Reply-To: <87sg2hyie1.fsf@igel.home> (message from Andreas Schwab on Thu, 20 May 2021 09:27:34 +0200) References: <83cztlq4wq.fsf@gnu.org> <87sg2hyie1.fsf@igel.home> X-Spam-Score: -2.3 (--) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) > From: Andreas Schwab > Cc: Ben Levy , 22763@debbugs.gnu.org > Date: Thu, 20 May 2021 09:27:34 +0200 > > >> if (pos < BEGV || pos > ZV) > >> args_out_of_range (make_int (start), make_int (ZV)); > >> > >> Shouldn't the lower bound condition be pos < start instead of pos < BEGV? > > > > No, because 'start' is the _byte_ position, > > But it should not be passed to args_out_of_range then. Right you are; fixed. From unknown Tue Jun 17 22:28:10 2025 X-Loop: help-debbugs@gnu.org Subject: bug#22763: 25.1.50; Feature Request -- A faster method to obtain line number at position. Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 20 May 2021 09:09:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 22763 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: fixed To: Ben Levy Cc: 22763@debbugs.gnu.org Received: via spool by 22763-submit@debbugs.gnu.org id=B22763.162150171919109 (code B ref 22763); Thu, 20 May 2021 09:09:02 +0000 Received: (at 22763) by debbugs.gnu.org; 20 May 2021 09:08:39 +0000 Received: from localhost ([127.0.0.1]:33087 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ljefX-0004y9-Bp for submit@debbugs.gnu.org; Thu, 20 May 2021 05:08:39 -0400 Received: from eggs.gnu.org ([209.51.188.92]:42018) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ljefW-0004xx-Hf for 22763@debbugs.gnu.org; Thu, 20 May 2021 05:08:38 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]:52778) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ljefQ-0006fj-UB; Thu, 20 May 2021 05:08:33 -0400 Received: from 84.94.185.95.cable.012.net.il ([84.94.185.95]:2937 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ljefQ-0004eG-Fp; Thu, 20 May 2021 05:08:32 -0400 Date: Thu, 20 May 2021 12:08:43 +0300 Message-Id: <834kexpyas.fsf@gnu.org> From: Eli Zaretskii In-Reply-To: <5vjNVOqvf9dNS_C5IpDYnu5V0nwdAkY0R5doUtx_Y4DgskVITLuZm09swlKj7PRY9g47nwei35U-4fRO_e5Tw7VrAK7RynVKHiY3kes_FOw=@protonmail.com> (bug-gnu-emacs@gnu.org) References: <83cztlq4wq.fsf@gnu.org> <87sg2hyie1.fsf@igel.home> <5vjNVOqvf9dNS_C5IpDYnu5V0nwdAkY0R5doUtx_Y4DgskVITLuZm09swlKj7PRY9g47nwei35U-4fRO_e5Tw7VrAK7RynVKHiY3kes_FOw=@protonmail.com> X-Spam-Score: -2.3 (--) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) > Date: Thu, 20 May 2021 07:35:21 +0000 > From: Ben Levy via "Bug reports for GNU Emacs, > the Swiss army knife of text editors" > > > No, because 'start' is the byte position. > > Oh, I was confused, sorry. In that case, I think the issue I'm having > is that it still compares to BEGV even when absolute is non-nil. > I think it should compare to BEG instead. No, because POSITION should still be in the accessible portion of the buffer. The function only counts the lines since from BOB, but that doesn't imply POSITION can be outside BEGV..ZV. > Also this, and I think the comment has a typo ("n" should be "in"?). Yes, already fixed. Thanks. From unknown Tue Jun 17 22:28:10 2025 X-Loop: help-debbugs@gnu.org Subject: bug#22763: 25.1.50; Feature Request -- A faster method to obtain line number at position. References: In-Reply-To: Resent-From: Ben Levy Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 20 May 2021 19:54:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 22763 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: fixed To: "22763@debbugs.gnu.org" <22763@debbugs.gnu.org> Reply-To: Ben Levy Received: via spool by 22763-submit@debbugs.gnu.org id=B22763.16215404227477 (code B ref 22763); Thu, 20 May 2021 19:54:02 +0000 Received: (at 22763) by debbugs.gnu.org; 20 May 2021 19:53:42 +0000 Received: from localhost ([127.0.0.1]:35251 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ljojl-0001wX-TT for submit@debbugs.gnu.org; Thu, 20 May 2021 15:53:42 -0400 Received: from mail-40140.protonmail.ch ([185.70.40.140]:17038) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ljojh-0001wF-9R for 22763@debbugs.gnu.org; Thu, 20 May 2021 15:53:41 -0400 Date: Thu, 20 May 2021 19:53:24 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=protonmail.com; s=protonmail; t=1621540410; bh=y+kd6Gg/FJqy54i/6W92Yq8+j4rzquIxwYHRk2fSNM0=; h=Date:To:From:Reply-To:Subject:From; b=dMRcZn4GelExJqzRAX/HFZ0LiVN6eXerqbf7cpSFabSgnufcTU1xheADZsR49a3kF Pe8zW9hCet31RLvuhDDs3947xFFWa7Fn2T1iOWjWZSX0O3jW9LAaChlr3XqlMzJtt9 YYdRriAtJk4dyHecI0XhCwyQZAgeG+864NZ7mCU8= From: Ben Levy Message-ID: <1TyanmjF6SBvziMpm9jWhwA0kDQ9iG5jzO7S0dTBDQjNe1sc7te_PrVSR1_pGXPFgQzlDEX2Nq5NK-wJiHQyCDhemaevOVf527K_I1jGvIw=@protonmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-1.2 required=10.0 tests=ALL_TRUSTED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM shortcircuit=no autolearn=disabled version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on mailout.protonmail.ch X-Spam-Score: 0.0 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) I'm not 100% sure about this, but it looks like when line-number-at-pos was written in elisp, it didn't do any bounds check, and instead called (widen) before counting lines. Did the elisp version have unintended behavior, or are the differences with the C version a regression? I think it's causing this bug: https://github.com/io12/good-scroll.el/issues/16 From unknown Tue Jun 17 22:28:10 2025 X-Loop: help-debbugs@gnu.org Subject: bug#22763: 25.1.50; Feature Request -- A faster method to obtain line number at position. Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 20 May 2021 20:11:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 22763 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: fixed To: Ben Levy Cc: 22763@debbugs.gnu.org Received: via spool by 22763-submit@debbugs.gnu.org id=B22763.16215414119217 (code B ref 22763); Thu, 20 May 2021 20:11:02 +0000 Received: (at 22763) by debbugs.gnu.org; 20 May 2021 20:10:11 +0000 Received: from localhost ([127.0.0.1]:35259 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ljozj-0002Ob-G0 for submit@debbugs.gnu.org; Thu, 20 May 2021 16:10:11 -0400 Received: from eggs.gnu.org ([209.51.188.92]:35636) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ljozg-0002OH-QY for 22763@debbugs.gnu.org; Thu, 20 May 2021 16:10:10 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]:45168) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ljozb-0003AY-Cx; Thu, 20 May 2021 16:10:03 -0400 Received: from 84.94.185.95.cable.012.net.il ([84.94.185.95]:1219 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ljoza-0005Gx-Hh; Thu, 20 May 2021 16:10:03 -0400 Date: Thu, 20 May 2021 23:09:58 +0300 Message-Id: <83h7ixnp49.fsf@gnu.org> From: Eli Zaretskii In-Reply-To: <1TyanmjF6SBvziMpm9jWhwA0kDQ9iG5jzO7S0dTBDQjNe1sc7te_PrVSR1_pGXPFgQzlDEX2Nq5NK-wJiHQyCDhemaevOVf527K_I1jGvIw=@protonmail.com> (bug-gnu-emacs@gnu.org) References: <1TyanmjF6SBvziMpm9jWhwA0kDQ9iG5jzO7S0dTBDQjNe1sc7te_PrVSR1_pGXPFgQzlDEX2Nq5NK-wJiHQyCDhemaevOVf527K_I1jGvIw=@protonmail.com> X-Spam-Score: -2.3 (--) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) > Date: Thu, 20 May 2021 19:53:24 +0000 > From: Ben Levy via "Bug reports for GNU Emacs, > the Swiss army knife of text editors" > > I'm not 100% sure about this, but it looks like when > line-number-at-pos was written in elisp, it didn't do > any bounds check, and instead called (widen) before > counting lines. Did the elisp version have unintended > behavior, or are the differences with the C version > a regression? I cannot answer that, because I don't understand what regression are you talking about. There's no need to widen the buffer in order to scan buffer text in C, AFAIK. > I think it's causing this bug: > https://github.com/io12/good-scroll.el/issues/16 Please explain the connection. I've read that discussion, but didn't see any data that would indicate this function is the culprit. At the very least, please tell which arguments are passed to line-number-at-pos in the problematic case, and what is the narrowed region. From unknown Tue Jun 17 22:28:10 2025 X-Loop: help-debbugs@gnu.org Subject: bug#22763: 25.1.50; Feature Request -- A faster method to obtain line number at position. References: In-Reply-To: Resent-From: Ben Levy Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 20 May 2021 20:41:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 22763 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: fixed To: "22763@debbugs.gnu.org" <22763@debbugs.gnu.org> Reply-To: Ben Levy Received: via spool by 22763-submit@debbugs.gnu.org id=B22763.162154324612501 (code B ref 22763); Thu, 20 May 2021 20:41:02 +0000 Received: (at 22763) by debbugs.gnu.org; 20 May 2021 20:40:46 +0000 Received: from localhost ([127.0.0.1]:35301 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ljpTJ-0003FZ-Nm for submit@debbugs.gnu.org; Thu, 20 May 2021 16:40:45 -0400 Received: from mail-40135.protonmail.ch ([185.70.40.135]:24557) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ljpTF-0003F3-OA for 22763@debbugs.gnu.org; Thu, 20 May 2021 16:40:44 -0400 Date: Thu, 20 May 2021 20:40:31 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=protonmail.com; s=protonmail; t=1621543235; bh=wcWTNjQsPxkFVfuxw4doPPjt/UOWt202zWO/7JwQmgw=; h=Date:To:From:Reply-To:Subject:From; b=bkY2U7SGr3Owbipri5+LjpkCw+vlpWZV3bPqZufbtr9kHLLI8CLvqFoVcSbsl9Po5 tpVlycm0tQR1vgpbqfAwEnufyTp6db0UVoRTNPlDBOTHrFf6VoObULVGdB6pAkoU2G irOUi7expxXggIHSuXmd2om8lyE9z/GBRlW7PeEc= From: Ben Levy Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-1.2 required=10.0 tests=ALL_TRUSTED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM shortcircuit=no autolearn=disabled version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on mailout.protonmail.ch X-Spam-Score: -0.0 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) > Please explain the connection. Here's a minimal example (sorry I didn't try to do this earlier): (with-temp-buffer (insert "foo\nbar\nbaz") (narrow-to-region 4 5) (message "%s" (line-number-at-pos 1 t))) On the latest master (ef7a6eec20), this errors with Args out of range: 1, 4, 5 But on emacs-27.2, it prints "1". >From what I can tell, this is because the lisp version of line-number-at-po= s allowed the argument to be outside the visible range, and it widened before counting lines to allow this. From unknown Tue Jun 17 22:28:10 2025 X-Loop: help-debbugs@gnu.org Subject: bug#22763: 25.1.50; Feature Request -- A faster method to obtain line number at position. Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 21 May 2021 05:48:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 22763 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: fixed To: Ben Levy Cc: 22763@debbugs.gnu.org Received: via spool by 22763-submit@debbugs.gnu.org id=B22763.16215760267579 (code B ref 22763); Fri, 21 May 2021 05:48:02 +0000 Received: (at 22763) by debbugs.gnu.org; 21 May 2021 05:47:06 +0000 Received: from localhost ([127.0.0.1]:35570 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ljy01-0001yB-Qc for submit@debbugs.gnu.org; Fri, 21 May 2021 01:47:06 -0400 Received: from eggs.gnu.org ([209.51.188.92]:60836) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ljxzy-0001xc-OK for 22763@debbugs.gnu.org; Fri, 21 May 2021 01:47:03 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]:32808) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ljxzo-0003RW-0x; Fri, 21 May 2021 01:46:55 -0400 Received: from 84.94.185.95.cable.012.net.il ([84.94.185.95]:4534 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ljxzl-0007IA-1H; Fri, 21 May 2021 01:46:51 -0400 Date: Fri, 21 May 2021 08:46:45 +0300 Message-Id: <83eee0ocze.fsf@gnu.org> From: Eli Zaretskii In-Reply-To: (bug-gnu-emacs@gnu.org) References: X-Spam-Score: -2.3 (--) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) > Date: Thu, 20 May 2021 20:40:31 +0000 > From: Ben Levy via "Bug reports for GNU Emacs, > the Swiss army knife of text editors" > > (with-temp-buffer > (insert "foo\nbar\nbaz") > (narrow-to-region 4 5) > (message "%s" (line-number-at-pos 1 t))) > > On the latest master (ef7a6eec20), this errors with > > Args out of range: 1, 4, 5 > > But on emacs-27.2, it prints "1". This is the expected behavior: the POSITION argument must be in the accessible portion of the buffer, like every position argument in Emacs. A Lisp program which calls this function like above has a bug that needs to be fixed. This is not a bug. > >From what I can tell, this is because the lisp version of line-number-at-pos > allowed the argument to be outside the visible range, and it widened before > counting lines to allow this. Right, the Lisp implementation was incorrect, and failed to do the test before widening.