From unknown Mon Aug 18 11:27:46 2025 X-Loop: help-debbugs@gnu.org Subject: bug#37393: 26.2.90; [PATCH] Speed up 'csv-align-fields' Resent-From: Simen =?UTF-8?Q?Heggest=C3=B8yl?= Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 12 Sep 2019 17:08:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 37393 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch To: 37393@debbugs.gnu.org Cc: Stefan Monnier , Leo Liu X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Received: via spool by submit@debbugs.gnu.org id=B.15683080633009 (code B ref -1); Thu, 12 Sep 2019 17:08:01 +0000 Received: (at submit) by debbugs.gnu.org; 12 Sep 2019 17:07:43 +0000 Received: from localhost ([127.0.0.1]:44065 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1i8SZK-0000mS-GA for submit@debbugs.gnu.org; Thu, 12 Sep 2019 13:07:42 -0400 Received: from lists.gnu.org ([209.51.188.17]:53341) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1i8SZJ-0000mL-97 for submit@debbugs.gnu.org; Thu, 12 Sep 2019 13:07:41 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:39005) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i8SZH-0004Ty-Tl for bug-gnu-emacs@gnu.org; Thu, 12 Sep 2019 13:07:41 -0400 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: ** X-Spam-Status: No, score=2.8 required=5.0 tests=BAYES_50,FREEMAIL_FROM, SPOOFED_FREEMAIL,URIBL_BLOCKED autolearn=disabled version=3.3.2 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1i8SZG-0005lW-7O for bug-gnu-emacs@gnu.org; Thu, 12 Sep 2019 13:07:39 -0400 Received: from mail-lj1-x22a.google.com ([2a00:1450:4864:20::22a]:40530) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1i8SZF-0005l3-UI for bug-gnu-emacs@gnu.org; Thu, 12 Sep 2019 13:07:38 -0400 Received: by mail-lj1-x22a.google.com with SMTP id 7so24306078ljw.7 for ; Thu, 12 Sep 2019 10:07:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=message-id:from:to:cc:subject:date:mime-version; bh=DYs8gJwEU+28u6199VOZSBEJ4TNRDlFnrJv94Er/8WU=; b=HE8rD5zHChKkQP5K7mPJUyPLb4RWS5sHhsaQKirQokaGkTz/Ic1ooaHaqwQOVXw0MP MMSvHBr7/lUL32PGp3KDp8fC4KqsuBmbEnlxsZOFj90BxIbKJTEfEB35kCTA9NpAxXPK q8h9QemrrNr16bXfafzwghLgGWm6rDuTEd9EB1/NmNn81qlB67/cq+nsCmUGxT/h5/aX 82EyLKv1ORMZtuHTDxnKoWepau2YVbEooKeBVh9QvryITDmhxLJ8k3OqwE5bvxhtKSdb Q0m+OfgtJliJ16WodUkRYZ1cmmKcmh2l+RiUPGPl0SD5SZem9E5IFstUUBL/zACCNynR PUpg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:message-id:from:to:cc:subject:date:mime-version; bh=DYs8gJwEU+28u6199VOZSBEJ4TNRDlFnrJv94Er/8WU=; b=O0NTfuov92aF7RuMUfWC3aTOnbVJEVQQUqRgP6VJ4zFt/MEPh4b5BDAZqB+BO0SxMm +Cf61rT936RjTf7+aqbzmORGlMjDfoIszV9YHJ3nWJ5ISGrgnFPwkuDsZrfgYWrzehRe X+nnutH0ezl7cK5Psrn06DUMqPArs7/7sbx4JhXEsezvnHf9Kvx0YuSavZW5KDSM8+ks rNkyQ/Ug+4ADm4uBa4CsWQcW1AIyMRXD/0tBg/ApjN0wXZZLedddRTG3ysqUZ0OGW42O kGLKJyrvlNpuOeQTH52JK5fMnODj26sXosY24pA4oMQkmokPJaek7rSckRrM+xFdB8Xm 1mMQ== X-Gm-Message-State: APjAAAVktcDyoRm3MJmFwSnYuw9BiUhltgmoS6B677L7tsGna8Dm8tBK Q07tMcKC+unkU4RsyG57X4k= X-Google-Smtp-Source: APXvYqwAeGIfmabx3wq0hD4s2ick+1g1u56RRKX9/bN4bOwCnrk+t1kPsISFGmDt5ztgMkVqAsqSIQ== X-Received: by 2002:a2e:83d6:: with SMTP id s22mr27346168ljh.104.1568308055485; Thu, 12 Sep 2019 10:07:35 -0700 (PDT) Received: from ae25 (cm-84.210.143.4.getinternet.no. [84.210.143.4]) by smtp.gmail.com with ESMTPSA id v10sm5818211ljc.64.2019.09.12.10.07.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 Sep 2019 10:07:34 -0700 (PDT) Message-ID: <5d7a7b56.1c69fb81.c32f6.840d@mx.google.com> X-Google-Original-Message-ID: <87sgp1qw8a.fsf@simenheg@gmail.com> From: Simen =?UTF-8?Q?Heggest=C3=B8yl?= Date: Thu, 12 Sep 2019 19:07:33 +0200 MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::22a 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: -0.3 (/) --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable The attached patch attempts to speed up the 'csv-align-fields' command by avoiding expensive calls to 'current-column', instead reusing field widths already computed by 'csv--column-widths'. I felt an urge to speed up the command a bit while working with large (100 000+ lines) CSV files. Below are benchmarks produced by running (benchmark 3 '(csv-align-fields nil (point-min) (point-max))) in three CSV files from the real world of various sizes. In these cases the speedup seems to be around 1.5x=E2=80=942x. ~400 line file: Before: Elapsed time: 0.175867s After: Elapsed time: 0.086809s ~50 000 line file: Before: Elapsed time: 34.665853s (7.480686s in 35 GCs) After: Elapsed time: 24.349081s (7.154716s in 27 GCs) ~110 000 line file: Before: Elapsed time: 82.444038s (19.799686s in 51 GCs) After: Elapsed time: 40.184331s (9.037813s in 25 GCs) (I've put on CC the two of you who seem to have done most of the work on this mode lately, hope that's OK.) -- Simen --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=0001-Speed-up-csv-align-fields.patch >From 4fc82f1f66c736bcfbc15d20ff53bd3e21e8a8e1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Simen=20Heggest=C3=B8yl?= Date: Thu, 12 Sep 2019 18:54:28 +0200 Subject: [PATCH] Speed up 'csv-align-fields' * packages/csv-mode/csv-mode.el: Bump version number and make the dependency on Emacs 24.1 or higher explicit. (csv--column-widths): Return the field widths as well. (csv-align-fields): Speed up by using the field widths already computed by 'csv--column-widths'. --- packages/csv-mode/csv-mode.el | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/packages/csv-mode/csv-mode.el b/packages/csv-mode/csv-mode.el index 40f70330a..dc2555687 100644 --- a/packages/csv-mode/csv-mode.el +++ b/packages/csv-mode/csv-mode.el @@ -4,7 +4,8 @@ ;; Author: "Francis J. Wright" ;; Time-stamp: <23 August 2004> -;; Version: 1.7 +;; Version: 1.8 +;; Package-Requires: ((emacs "24.1")) ;; Keywords: convenience ;; This package is free software; you can redistribute it and/or modify @@ -969,24 +970,26 @@ The fields yanked are those last killed by `csv-kill-fields'." (and (overlay-get o 'csv) (delete-overlay o))) (defun csv--column-widths () - (let ((widths '())) + (let ((column-widths '()) + (field-widths '())) ;; Construct list of column widths: (while (not (eobp)) ; for each record... (or (csv-not-looking-at-record) - (let ((w widths) + (let ((w column-widths) (col (current-column)) - x) + field-width) (while (not (eolp)) (csv-end-of-field) - (setq x (- (current-column) col)) ; Field width. + (setq field-width (- (current-column) col)) + (push field-width field-widths) (if w - (if (> x (car w)) (setcar w x)) - (setq w (list x) - widths (nconc widths w))) + (if (> field-width (car w)) (setcar w field-width)) + (setq w (list field-width) + column-widths (nconc column-widths w))) (or (eolp) (forward-char)) ; Skip separator. (setq w (cdr w) col (current-column))))) (forward-line)) - widths)) + (list column-widths (nreverse field-widths)))) (defun csv-align-fields (hard beg end) "Align all the fields in the region to form columns. @@ -1017,23 +1020,22 @@ If there is no selected region, default to the whole buffer." (narrow-to-region beg end) (set-marker end nil) (goto-char (point-min)) - (let ((widths (csv--column-widths))) + (pcase-let ((`(,column-widths ,field-widths) (csv--column-widths))) ;; Align fields: (goto-char (point-min)) (while (not (eobp)) ; for each record... (unless (csv-not-looking-at-record) - (let ((w widths) + (let ((w column-widths) (column 0)) ;Desired position of left-side of this column. (while (and w (not (eolp))) (let* ((beg (point)) (align-padding (if (bolp) 0 csv-align-padding)) (left-padding 0) (right-padding 0) - (field-width - (- (- (current-column) - (progn (csv-end-of-field) (current-column))))) + (field-width (pop field-widths)) (column-width (pop w)) (x (- column-width field-width))) ; Required padding. + (csv-end-of-field) (set-marker end (point)) ; End of current field. ;; beg = beginning of current field ;; end = (point) = end of current field -- 2.23.0 --=-=-=-- From unknown Mon Aug 18 11:27:46 2025 X-Loop: help-debbugs@gnu.org Subject: bug#37393: 26.2.90; [PATCH] Speed up 'csv-align-fields' Resent-From: Stefan Monnier Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 12 Sep 2019 17:47:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 37393 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch To: Simen =?UTF-8?Q?Heggest=C3=B8yl?= Cc: 37393@debbugs.gnu.org, sdl.web@gmail.com X-Debbugs-Original-Cc: bug-gnu-emacs@gnu.org, Leo Liu Received: via spool by submit@debbugs.gnu.org id=B.15683104066961 (code B ref -1); Thu, 12 Sep 2019 17:47:02 +0000 Received: (at submit) by debbugs.gnu.org; 12 Sep 2019 17:46:46 +0000 Received: from localhost ([127.0.0.1]:44086 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1i8TB7-0001oC-P0 for submit@debbugs.gnu.org; Thu, 12 Sep 2019 13:46:46 -0400 Received: from lists.gnu.org ([209.51.188.17]:51829) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1i8TB6-0001o2-Cv for submit@debbugs.gnu.org; Thu, 12 Sep 2019 13:46:44 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:49439) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i8TB5-0003an-1R for bug-gnu-emacs@gnu.org; Thu, 12 Sep 2019 13:46:44 -0400 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,URIBL_BLOCKED autolearn=disabled version=3.3.2 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1i8TB3-0007F0-Dc for bug-gnu-emacs@gnu.org; Thu, 12 Sep 2019 13:46:42 -0400 Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:21354) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1i8TB3-0007Ec-6Z for bug-gnu-emacs@gnu.org; Thu, 12 Sep 2019 13:46:41 -0400 Received: from pmg2.iro.umontreal.ca (localhost.localdomain [127.0.0.1]) by pmg2.iro.umontreal.ca (Proxmox) with ESMTP id 068BF81179; Thu, 12 Sep 2019 13:46:40 -0400 (EDT) Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg2.iro.umontreal.ca (Proxmox) with ESMTP id 4843680ACB; Thu, 12 Sep 2019 13:46:38 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1568310398; bh=SIzfflss0zsxR4cFG/fT9NE4aMgTlgBpYqXUPJMlXD8=; h=From:To:Cc:Subject:References:Date:In-Reply-To:From; b=TjLOoCZpHOcITbTQdaefhhxRro8d5eV05hdeznPEuS1ZwOH7MlM4AISY0/UYhF7fd QSG2t92LV5+w12wmtObtcEhshNBd4emJq0SCSXeRs9q9sgCpl54NXVcU7kA6CZgF8q krb/gR9/ui2rb5ZdmPXQk8yzw2xRrjeNWpIK4zQVhpW0nBixEe96BQPw4k6+LiV9WY flq5Ra2fxMr7QNCSDp7WOusy1oV+lBhcs31+JplAMhLlk6KAHmqSzbt85INJOluK1A DWqiNl6PwOeCCEDTbbCIxd1XOjcCGwcjLCD9Ft05jQlxLtN2VK5NHlehVssVpQ/Upd 8Wl748F75El2Q== Received: from lechazo (lechon.iro.umontreal.ca [132.204.27.242]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id 1225512044D; Thu, 12 Sep 2019 13:46:38 -0400 (EDT) From: Stefan Monnier Message-ID: References: <5d7a7b56.1c69fb81.c32f6.840d@mx.google.com> Date: Thu, 12 Sep 2019 13:46:36 -0400 In-Reply-To: <5d7a7b56.1c69fb81.c32f6.840d@mx.google.com> ("Simen \=\?windows-1252\?Q\?Heggest\=F8yl\=22's\?\= message of "Thu, 12 Sep 2019 19:07:33 +0200") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 132.204.25.50 X-Spam-Score: -1.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: -2.3 (--) > The attached patch attempts to speed up the 'csv-align-fields' command > by avoiding expensive calls to 'current-column', instead reusing field > widths already computed by 'csv--column-widths'. Sounds good. I rarely use large CSV files, but I know the operation is slo= w. I'm OK with the patch, tho please see my comment below. > I felt an urge to speed up the command a bit while working with large > (100 000+ lines) CSV files. Below are benchmarks produced by running > > (benchmark 3 '(csv-align-fields nil (point-min) (point-max))) > > in three CSV files from the real world of various sizes. In these cases > the speedup seems to be around 1.5x=E2=80=942x. > > ~400 line file: > Before: Elapsed time: 0.175867s > After: Elapsed time: 0.086809s > > ~50 000 line file: > Before: Elapsed time: 34.665853s (7.480686s in 35 GCs) > After: Elapsed time: 24.349081s (7.154716s in 27 GCs) > > ~110 000 line file: > Before: Elapsed time: 82.444038s (19.799686s in 51 GCs) > After: Elapsed time: 40.184331s (9.037813s in 25 GCs) 40s is still slow, but a factor of 2 is good, thanks. If you're interested in this line, I think there are two avenues to improve the behavior further: - align lazily via jit-lock (this way the time is determined by the amount of text displayed rather than the total file size). - make align-fields' into a mode, where fields are kept aligned even while the buffer is modified. > (defun csv--column-widths () > - (let ((widths '())) > + (let ((column-widths '()) > + (field-widths '())) I think the return value is now sufficiently complex that the function deserves a docstring describing it. Stefan From unknown Mon Aug 18 11:27:46 2025 X-Loop: help-debbugs@gnu.org Subject: bug#37393: 26.2.90; [PATCH] Speed up 'csv-align-fields' References: <5d7a7b56.1c69fb81.c32f6.840d@mx.google.com> Resent-From: Simen =?UTF-8?Q?Heggest=C3=B8yl?= Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 15 Sep 2019 15:56:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 37393 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch To: Stefan Monnier Cc: 37393@debbugs.gnu.org, sdl.web@gmail.com Received: via spool by 37393-submit@debbugs.gnu.org id=B37393.156856295418664 (code B ref 37393); Sun, 15 Sep 2019 15:56:02 +0000 Received: (at 37393) by debbugs.gnu.org; 15 Sep 2019 15:55:54 +0000 Received: from localhost ([127.0.0.1]:48646 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1i9WsT-0004qy-Kl for submit@debbugs.gnu.org; Sun, 15 Sep 2019 11:55:53 -0400 Received: from mail-lj1-f179.google.com ([209.85.208.179]:46058) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1i9WsR-0004ql-Ty for 37393@debbugs.gnu.org; Sun, 15 Sep 2019 11:55:52 -0400 Received: by mail-lj1-f179.google.com with SMTP id q64so20947285ljb.12 for <37393@debbugs.gnu.org>; Sun, 15 Sep 2019 08:55:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=message-id:from:to:cc:subject:in-reply-to:date:mime-version; bh=5UR4hpOHyR4jyNgyVWKWMw2YTBP/GLyHkPR/RbeZnwI=; b=NI3I/03K45UeOqxpxAn0ta9a828+GBvHDzSxWVaYzleyffr5SGgeWPMvqWrtGApgjy Ukq9GUzHBIgAm/QJufZzObpZeimvttVXV/ND01k5OaR7qsiVQK1/mgMnVBkTL/9253OL 9EQeX8e8KOPPkIOJfEgDO5FSeuRFZsJZwzkgsHZ2eNJMghK+ku9+hcan3dzndq5sP5AO jVuhLB2sllykjaUY7f7FwnHmf78Bwd7bl2BmedRMKeS7OwkwWx63C/refvp53wffHhc7 NoPbdckd2clwgO+5KiVqM78nL9JfN+n9J3S9WMP47SoNCfYpHlHwizFls/jmZFu4G0b0 z0xQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:message-id:from:to:cc:subject:in-reply-to:date :mime-version; bh=5UR4hpOHyR4jyNgyVWKWMw2YTBP/GLyHkPR/RbeZnwI=; b=Abc30XvG7Kcg+nvd2J1OV5ipMMRR27tI61ZE9IiDy0xNFhVUhkR8JDQnQKItSrcTCf WnkDsQrBUP7c5d3kS7p0ZrDRMflNn6gL6fQ8h9hBfXY7FJXqQqbZG4HnfAEEwXtFbOJ9 0Q7/fGecX9cU9wwGgLXxI1XnRWv4GywXzmOn9FKHDGclBvEAOFGCJHwjLhhducjA7+r3 KU55nAsa50OR/NDfI5ix0D24MJIm0wnQGRAjYBKBPhQVohB/u+6sk8AtZraIDZIbruKN TjPUGLI5COQnaKpopWXEqIeTw2peJs1PWEqloAF+iRf2UaRSZ8Ghxf8OrxIalk7mQLFT 58sA== X-Gm-Message-State: APjAAAW1sEX5sluiqMQSmk4q8WUx2n0YibaA9CkHS2blNVMAL78o+Irn pqr8vWlK8X9nFALyHsxpXxQ= X-Google-Smtp-Source: APXvYqwzOJnmlRs478EA2pSCef7MCYIu+ygiazQ1KKyk1gPGMs6nK0pYavgjd0T0VZ4oIVKMXDUfdw== X-Received: by 2002:a2e:2c01:: with SMTP id s1mr35268632ljs.113.1568562945726; Sun, 15 Sep 2019 08:55:45 -0700 (PDT) Received: from ae25 (cm-84.210.143.4.getinternet.no. [84.210.143.4]) by smtp.gmail.com with ESMTPSA id m18sm8336642lfb.73.2019.09.15.08.55.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 15 Sep 2019 08:55:44 -0700 (PDT) Message-ID: <5d7e5f00.1c69fb81.43f55.3fa2@mx.google.com> X-Google-Original-Message-ID: <87zhj5sge7.fsf@simenheg@gmail.com> From: Simen =?UTF-8?Q?Heggest=C3=B8yl?= In-Reply-To: (message from Stefan Monnier on Thu, 12 Sep 2019 13:46:36 -0400) Date: Sun, 15 Sep 2019 17:55:44 +0200 MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" 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 (-) --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Stefan Monnier writes: > Sounds good. I rarely use large CSV files, but I know the operation is s= low. > > I'm OK with the patch, tho please see my comment below. Thanks for reviewing it. > 40s is still slow, but a factor of 2 is good, thanks. Yes (though 40s is the time for all three benchmark runs, so one alignment is 40s/3). > If you're interested in this line, I think there are two avenues to > improve the behavior further: > - align lazily via jit-lock (this way the time is determined by the > amount of text displayed rather than the total file size). Wouldn't that still depend on knowing the column widths? I find that the column width computation is taking about 80% of the time when calling 'csv-align-fields' (after the patch). > - make align-fields' into a mode, where fields are kept aligned even while > the buffer is modified. That sounds nice. >> (defun csv--column-widths () >> - (let ((widths '())) >> + (let ((column-widths '()) >> + (field-widths '())) > > I think the return value is now sufficiently complex that the function > deserves a docstring describing it. Agreed, I'll add one before I install the patch. I've also attached a new suggestion for speeding up the column width computation itself by eliminating another 'current-column'-call. I'm not too sure about its correctness yet, but it seems to work in a few tests I've done, and it sped up 'csv--column-widths' by a factor of 1.3=E2=80=931= .4. --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=0001-WIP.patch >From c3c077170aefa8ba0cd5d8f8b824c85eb0f01a66 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Simen=20Heggest=C3=B8yl?= Date: Sun, 15 Sep 2019 17:31:40 +0200 Subject: [PATCH] WIP --- packages/csv-mode/csv-mode.el | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/packages/csv-mode/csv-mode.el b/packages/csv-mode/csv-mode.el index dc2555687..00107f51e 100644 --- a/packages/csv-mode/csv-mode.el +++ b/packages/csv-mode/csv-mode.el @@ -976,18 +976,26 @@ The fields yanked are those last killed by `csv-kill-fields'." (while (not (eobp)) ; for each record... (or (csv-not-looking-at-record) (let ((w column-widths) - (col (current-column)) + (col-beg (current-column)) + col-end field-width) (while (not (eolp)) (csv-end-of-field) - (setq field-width (- (current-column) col)) + (setq col-end (current-column)) + (setq field-width (- col-end col-beg)) (push field-width field-widths) (if w (if (> field-width (car w)) (setcar w field-width)) (setq w (list field-width) column-widths (nconc column-widths w))) - (or (eolp) (forward-char)) ; Skip separator. - (setq w (cdr w) col (current-column))))) + (unless (eolp) + (forward-char) ; Skip separator. + (setq w (cdr w)) + (setq col-beg (if (= (char-before) ?\t) + (* (/ (+ col-end tab-width) + tab-width) + tab-width) + (+ col-end (char-width (char-before))))))))) (forward-line)) (list column-widths (nreverse field-widths)))) -- 2.23.0 --=-=-= Content-Type: text/plain -- Simen --=-=-=-- From unknown Mon Aug 18 11:27:46 2025 X-Loop: help-debbugs@gnu.org Subject: bug#37393: 26.2.90; [PATCH] Speed up 'csv-align-fields' Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 15 Sep 2019 16:18:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 37393 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch To: Simen =?UTF-8?Q?Heggest=C3=B8yl?= Cc: 37393@debbugs.gnu.org, monnier@iro.umontreal.ca, sdl.web@gmail.com Received: via spool by 37393-submit@debbugs.gnu.org id=B37393.156856425921045 (code B ref 37393); Sun, 15 Sep 2019 16:18:01 +0000 Received: (at 37393) by debbugs.gnu.org; 15 Sep 2019 16:17:39 +0000 Received: from localhost ([127.0.0.1]:48671 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1i9XDW-0005TN-PH for submit@debbugs.gnu.org; Sun, 15 Sep 2019 12:17:39 -0400 Received: from eggs.gnu.org ([209.51.188.92]:43567) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1i9XDU-0005T6-Te for 37393@debbugs.gnu.org; Sun, 15 Sep 2019 12:17:37 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]:37563) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1i9XDP-0008Ea-H1; Sun, 15 Sep 2019 12:17:31 -0400 Received: from [176.228.60.248] (port=1144 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1i9XDO-0000Ww-6L; Sun, 15 Sep 2019 12:17:30 -0400 Date: Sun, 15 Sep 2019 19:17:49 +0300 Message-Id: <83blvly1n6.fsf@gnu.org> From: Eli Zaretskii In-reply-to: <5d7e5f00.1c69fb81.43f55.3fa2@mx.google.com> (message from Simen =?UTF-8?Q?Heggest=C3=B8yl?= on Sun, 15 Sep 2019 17:55:44 +0200) References: <5d7a7b56.1c69fb81.c32f6.840d@mx.google.com> <5d7e5f00.1c69fb81.43f55.3fa2@mx.google.com> MIME-version: 1.0 Content-type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] 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: Simen Heggestøyl > Date: Sun, 15 Sep 2019 17:55:44 +0200 > Cc: 37393@debbugs.gnu.org, sdl.web@gmail.com > > > If you're interested in this line, I think there are two avenues to > > improve the behavior further: > > - align lazily via jit-lock (this way the time is determined by the > > amount of text displayed rather than the total file size). > > Wouldn't that still depend on knowing the column widths? I find that the > column width computation is taking about 80% of the time when calling > 'csv-align-fields' (after the patch). I'm talking here about something I don't understand well enough, but did you try computing column width using vertical-motion? From unknown Mon Aug 18 11:27:46 2025 X-Loop: help-debbugs@gnu.org Subject: bug#37393: 26.2.90; [PATCH] Speed up 'csv-align-fields' Resent-From: Stefan Monnier Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 15 Sep 2019 18:44:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 37393 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch To: Simen =?UTF-8?Q?Heggest=C3=B8yl?= Cc: 37393@debbugs.gnu.org, sdl.web@gmail.com Received: via spool by 37393-submit@debbugs.gnu.org id=B37393.15685730074338 (code B ref 37393); Sun, 15 Sep 2019 18:44:02 +0000 Received: (at 37393) by debbugs.gnu.org; 15 Sep 2019 18:43:27 +0000 Received: from localhost ([127.0.0.1]:48719 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1i9ZUc-00017t-VD for submit@debbugs.gnu.org; Sun, 15 Sep 2019 14:43:27 -0400 Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:63033) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1i9ZUa-00017e-GQ for 37393@debbugs.gnu.org; Sun, 15 Sep 2019 14:43:25 -0400 Received: from pmg1.iro.umontreal.ca (localhost.localdomain [127.0.0.1]) by pmg1.iro.umontreal.ca (Proxmox) with ESMTP id 9DB9A1007C0; Sun, 15 Sep 2019 14:43:18 -0400 (EDT) Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg1.iro.umontreal.ca (Proxmox) with ESMTP id 9AB301005BA; Sun, 15 Sep 2019 14:43:16 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1568572996; bh=5qf0KTx1ElEOkVoMYKIh/qaCmDx02jRkfWDiwqc6g8M=; h=From:To:Cc:Subject:References:Date:In-Reply-To:From; b=dflfGTUycPTbvFm4RFfT2JKBQ0T+dY09/LMKEMJkRq6iFdAaZx1cW9fM6N2Dk40KJ b2p/NREv4LC9DMzFuW6An8FERoM5Hk5TmEBaPLtZdD+jj3hB00MxPfIztlfqMuZfGN QLlzmK/mTByf/L6jKFiZwxB9+5jUycpcvO068XKD/XRe1diyRYGr+0e2cFj8eJ+Bu0 WooeOF/oJhp0aEWXnUIfiR6LsyqXDf1dapatUrJLxdnpt0BTGMHOM7eYBsM9zs5C2N hroSmEsJYZOna3Y2QVYg3j0UWhOi4qluMgz0CQuY0Yl63fF5N0Scvc+xEMqx8angq5 aOHNBtDVC3F7g== Received: from alfajor (104-222-123-223.cpe.teksavvy.com [104.222.123.223]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id 4E0D4120604; Sun, 15 Sep 2019 14:43:16 -0400 (EDT) From: Stefan Monnier Message-ID: References: <5d7e5f00.1c69fb81.43f55.3fa2@mx.google.com> Date: Sun, 15 Sep 2019 14:43:14 -0400 In-Reply-To: <5d7e5f00.1c69fb81.43f55.3fa2@mx.google.com> ("Simen \=\?windows-1252\?Q\?Heggest\=F8yl\=22's\?\= message of "Sun, 15 Sep 2019 17:55:44 +0200") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.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.223 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: 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 (-) >> If you're interested in this line, I think there are two avenues to >> improve the behavior further: >> - align lazily via jit-lock (this way the time is determined by the >> amount of text displayed rather than the total file size). > Wouldn't that still depend on knowing the column widths? Of the whole file? No: instead you'd only use the max of the columns that you've seen so far. When it increases (thus invalidating alignment-overlays already created), you just "flush" those overlays and rebuild them. > I've also attached a new suggestion for speeding up the column width > computation itself by eliminating another 'current-column'-call. I'm not > too sure about its correctness yet, but it seems to work in a few tests > I've done, and it sped up 'csv--column-widths' by a factor of 1.3=E2=80= =931.4. Looks OK, but deserves a comment explaining that this computation of the new `col-beg` using tab-width and char-width is there to avoid an additional call to current-column (it's basically a "fast-current-column" which gets its extra speed from doing the work more incrementally, whereas current-column always starts counting from BOL). Maybe we could get yet more speedup by making it possible to pass to `current-column` (or a new C function) a start position along with its column, so we'd avoid re-traversing the part of the line that we've already processed. Stefan From unknown Mon Aug 18 11:27:46 2025 X-Loop: help-debbugs@gnu.org Subject: bug#37393: 26.2.90; [PATCH] Speed up 'csv-align-fields' References: <5d7a7b56.1c69fb81.c32f6.840d@mx.google.com> Resent-From: Simen =?UTF-8?Q?Heggest=C3=B8yl?= Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 17 Sep 2019 16:54:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 37393 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch To: Eli Zaretskii , Stefan Monnier Cc: 37393@debbugs.gnu.org, sdl.web@gmail.com Received: via spool by 37393-submit@debbugs.gnu.org id=B37393.156873919732740 (code B ref 37393); Tue, 17 Sep 2019 16:54:01 +0000 Received: (at 37393) by debbugs.gnu.org; 17 Sep 2019 16:53:17 +0000 Received: from localhost ([127.0.0.1]:53199 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1iAGj6-0008Vw-SI for submit@debbugs.gnu.org; Tue, 17 Sep 2019 12:53:17 -0400 Received: from mail-lj1-f181.google.com ([209.85.208.181]:34322) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1iAGj4-0008Vc-9f for 37393@debbugs.gnu.org; Tue, 17 Sep 2019 12:53:15 -0400 Received: by mail-lj1-f181.google.com with SMTP id h2so4315801ljk.1 for <37393@debbugs.gnu.org>; Tue, 17 Sep 2019 09:53:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=message-id:from:to:cc:subject:in-reply-to:date:mime-version; bh=rf1pehGAd/vylkpjDBKw8MnqOPGhFrqPcWsliSccShg=; b=FCXVdiJIyL1dqgnuJ2Nqgp+p0S2V4H6A78gr3+eB5DaVGbJHxUojKYZREzKaF0rMKR pKvRAC+c0cDIpTfyVVxQ0p67ugJrE3AiAUP6UkNvYyh3B4x1L0L287amSJmh3Htehwow 1krjMSPMlKq1ReFoV+BIm3Lcs/7Yz29aUhULccNekT7S0YzzvI4JPGWRwiYK6rXJ1hl2 vSGOnYOp3Svi2Tqsya57qzbCBchMupm4N34MvjdphOw/MYnBQvbH/B8g67mdCinWFxdR 7AuMnAeapv5NVMR6HmVQqZS1Qa7nZHz8Sn92eSqfUS5P9kbOO0/gsJyaJH+isEaImmgv kE3g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:message-id:from:to:cc:subject:in-reply-to:date :mime-version; bh=rf1pehGAd/vylkpjDBKw8MnqOPGhFrqPcWsliSccShg=; b=ly/TfXty1j2iqx/nAYmOxeaC4Ky/0QoEAZ+k2cPBKPjeF+QTAIgm0CN0+gYOOvvGXc WJ8U+Rqoijc8Gae6P32/axjZRz0pNk4y2Ojgfs7NHRHCucAxWUHvYh+NiEVeMeeOSYi6 rhQsBfm+9FUMkDywhzDFjD10bfuqwop81Q+hVC+2NpEPdudfWDB0KxGEK7YLp3wj6BZj azsFFmlSvOeUzGjz8SDMeUl1pc445E2bkZVUlplrLKtNx3bJ+unoOzwNnNd7CH5kX/ij NEpjiQV8kv20bs/J7m2W4zS9jH+1g7Ylu/XOCqH7EImNXd6lciyo1J69QTC6h1pLqUqX G5HQ== X-Gm-Message-State: APjAAAUPfHR+Imoi4OtAuvd79nFjvI1A7ODwlSvp/Du3xRn4v37Y/Gjr KyB0JpmoTfeaZADMgpLPlAs= X-Google-Smtp-Source: APXvYqxd3VQDUiBo3mxYLxgI1hzqmpAaGEohjVhV9wYC5ZZzYSQrI4Nrx1jM6VXo8Akk1TwdnPsvPw== X-Received: by 2002:a2e:3613:: with SMTP id d19mr2415240lja.57.1568739188210; Tue, 17 Sep 2019 09:53:08 -0700 (PDT) Received: from ae25 (cm-84.210.143.4.getinternet.no. [84.210.143.4]) by smtp.gmail.com with ESMTPSA id 134sm524544lfk.70.2019.09.17.09.53.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Sep 2019 09:53:07 -0700 (PDT) Message-ID: <5d810f73.1c69fb81.486b.2e0a@mx.google.com> X-Google-Original-Message-ID: <87k1a6g8zx.fsf@simenheg@gmail.com> From: Simen =?UTF-8?Q?Heggest=C3=B8yl?= In-Reply-To: (message from Stefan Monnier on Sun, 15 Sep 2019 14:43:14 -0400) Date: Tue, 17 Sep 2019 18:53:06 +0200 MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" 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 (-) --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Eli Zaretskii writes: > I'm talking here about something I don't understand well enough, but > did you try computing column width using vertical-motion? No, I haven't yet tried anything in that direction. Stefan Monnier writes: >>> If you're interested in this line, I think there are two avenues to >>> improve the behavior further: >>> - align lazily via jit-lock (this way the time is determined by the >>> amount of text displayed rather than the total file size). >> Wouldn't that still depend on knowing the column widths? > > Of the whole file? No: instead you'd only use the max of the columns that > you've seen so far. When it increases (thus invalidating > alignment-overlays already created), you just "flush" those overlays and > rebuild them. Wouldn't then the columns appear to jump about whenever a new max width is discovered? I also guess you'd lose the ability to do e.g. C-u 1000 C-n and stay in the same column? > Maybe we could get yet more speedup by making it possible to pass to > `current-column` (or a new C function) a start position along with its > column, so we'd avoid re-traversing the part of the line that we've > already processed. I think that sounds like a good idea; then my ugly "fast-current-column" patch from last time won't be needed. I have no prior experience with Emacs' C internals, but an initial naive attempt is attached. I've only tested it on some basic cases where it seems to behave correctly and gives a speedup factor of around 4,5x=E2=80=935x. Could this track be somet= hing worth exploring further? --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=0001-WIP.patch >From 16d8915b8ad96b2aa7fb0350468b4af847c5ff19 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Simen=20Heggest=C3=B8yl?= Date: Tue, 17 Sep 2019 17:32:00 +0200 Subject: [PATCH] WIP --- src/indent.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/indent.c b/src/indent.c index 1b589a710c..f2c525d882 100644 --- a/src/indent.c +++ b/src/indent.c @@ -46,6 +46,10 @@ #define CR 015 ptrdiff_t last_known_column_point; +/* Value of point byte when current_column was called. */ + +ptrdiff_t last_known_column_point_byte; + /* Value of MODIFF when current_column was called. */ static modiff_count last_known_column_modified; @@ -325,6 +329,7 @@ DEFUN ("current-column", Fcurrent_column, Scurrent_column, 0, 0, 0, invalidate_current_column (void) { last_known_column_point = 0; + last_known_column_point_byte = 0; } ptrdiff_t @@ -454,6 +459,7 @@ current_column (void) last_known_column = col; last_known_column_point = PT; + last_known_column_point_byte = PT_BYTE; last_known_column_modified = MODIFF; return col; @@ -545,6 +551,17 @@ scan_for_column (ptrdiff_t *endpos, EMACS_INT *goalcol, ptrdiff_t *prevcol) ptrdiff_t scan, scan_byte, next_boundary; scan = find_newline (PT, PT_BYTE, BEGV, BEGV_BYTE, -1, NULL, &scan_byte, 1); + + if (scan < last_known_column_point + && end > last_known_column_point + && MODIFF == last_known_column_modified) + { + scan = last_known_column_point; + scan_byte = last_known_column_point_byte; + col = last_known_column; + prev_col = last_known_column; + } + next_boundary = scan; window = Fget_buffer_window (Fcurrent_buffer (), Qnil); @@ -701,6 +718,7 @@ scan_for_column (ptrdiff_t *endpos, EMACS_INT *goalcol, ptrdiff_t *prevcol) last_known_column = col; last_known_column_point = PT; + last_known_column_point_byte = PT_BYTE; last_known_column_modified = MODIFF; if (goalcol) @@ -848,6 +866,7 @@ DEFUN ("indent-to", Findent_to, Sindent_to, 1, 2, "NIndent to column: ", last_known_column = mincol; last_known_column_point = PT; + last_known_column_point_byte = PT_BYTE; last_known_column_modified = MODIFF; XSETINT (column, mincol); @@ -1040,6 +1059,7 @@ COLUMN (otherwise). In addition, if FORCE is t, and the line is too short last_known_column = col; last_known_column_point = PT; + last_known_column_point_byte = PT_BYTE; last_known_column_modified = MODIFF; return make_fixnum (col); -- 2.23.0 --=-=-= Content-Type: text/plain -- Simen --=-=-=-- From unknown Mon Aug 18 11:27:46 2025 X-Loop: help-debbugs@gnu.org Subject: bug#37393: 26.2.90; [PATCH] Speed up 'csv-align-fields' Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 17 Sep 2019 17:24:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 37393 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch To: Simen =?UTF-8?Q?Heggest=C3=B8yl?= Cc: 37393@debbugs.gnu.org, monnier@iro.umontreal.ca, sdl.web@gmail.com Received: via spool by 37393-submit@debbugs.gnu.org id=B37393.15687410113539 (code B ref 37393); Tue, 17 Sep 2019 17:24:02 +0000 Received: (at 37393) by debbugs.gnu.org; 17 Sep 2019 17:23:31 +0000 Received: from localhost ([127.0.0.1]:53211 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1iAHCK-0000uz-U3 for submit@debbugs.gnu.org; Tue, 17 Sep 2019 13:23:29 -0400 Received: from eggs.gnu.org ([209.51.188.92]:43303) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1iAHCI-0000ue-Q7 for 37393@debbugs.gnu.org; Tue, 17 Sep 2019 13:23:27 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]:45051) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1iAHCD-00015l-DM; Tue, 17 Sep 2019 13:23:21 -0400 Received: from [176.228.60.248] (port=3106 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1iAHCC-0002nx-5x; Tue, 17 Sep 2019 13:23:20 -0400 Date: Tue, 17 Sep 2019 20:23:19 +0300 Message-Id: <83r24evnug.fsf@gnu.org> From: Eli Zaretskii In-reply-to: <5d810f73.1c69fb81.486b.2e0a@mx.google.com> (message from Simen =?UTF-8?Q?Heggest=C3=B8yl?= on Tue, 17 Sep 2019 18:53:06 +0200) References: <5d810f73.1c69fb81.486b.2e0a@mx.google.com> MIME-version: 1.0 Content-type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] 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: Simen Heggestøyl > Cc: 37393@debbugs.gnu.org, sdl.web@gmail.com > Date: Tue, 17 Sep 2019 18:53:06 +0200 > > > Maybe we could get yet more speedup by making it possible to pass to > > `current-column` (or a new C function) a start position along with its > > column, so we'd avoid re-traversing the part of the line that we've > > already processed. > > I think that sounds like a good idea; then my ugly "fast-current-column" > patch from last time won't be needed. Once again, risking to talk about something I don't clearly understand: vertical-motion already allows you to pass an argument which tells what is the current column. Any rationale to use current-column instead of vertical-motion? From unknown Mon Aug 18 11:27:46 2025 X-Loop: help-debbugs@gnu.org Subject: bug#37393: 26.2.90; [PATCH] Speed up 'csv-align-fields' Resent-From: Stefan Monnier Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 17 Sep 2019 19:13:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 37393 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch To: Simen =?UTF-8?Q?Heggest=C3=B8yl?= Cc: Eli Zaretskii , 37393@debbugs.gnu.org, sdl.web@gmail.com Received: via spool by 37393-submit@debbugs.gnu.org id=B37393.156874756016476 (code B ref 37393); Tue, 17 Sep 2019 19:13:02 +0000 Received: (at 37393) by debbugs.gnu.org; 17 Sep 2019 19:12:40 +0000 Received: from localhost ([127.0.0.1]:53266 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1iAItz-0004Hg-SS for submit@debbugs.gnu.org; Tue, 17 Sep 2019 15:12:40 -0400 Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:34595) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1iAItw-0004HN-Pq for 37393@debbugs.gnu.org; Tue, 17 Sep 2019 15:12:37 -0400 Received: from pmg1.iro.umontreal.ca (localhost.localdomain [127.0.0.1]) by pmg1.iro.umontreal.ca (Proxmox) with ESMTP id 24AA5100D1F; Tue, 17 Sep 2019 15:12:31 -0400 (EDT) Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg1.iro.umontreal.ca (Proxmox) with ESMTP id C2552100C6D; Tue, 17 Sep 2019 15:12:29 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1568747549; bh=jrpb8VOcJy7Bul35zEZs30FESLTrBYZWzk/Y6K3DlLw=; h=From:To:Cc:Subject:References:Date:In-Reply-To:From; b=acg6YJxSW0SXdoXVprqkzrY7FS0/n7zxeErOsDF6dDadDPbMu3oComePOhP8No60N gcLVzokd6dE8F6+JghUTmBui8HyWbgDG9BWOBrTR4Z6sA3kZZYytsmHUpjbxR16hVb Yqvm1YtCh9M8pBOZANQLE0PYz4sph77j7TWqPnAecuVmkSkTG3W37OOnz4gX/MgqBq sujDquH3LPzNARBlBki8TeZtmLHC6kNuqq7wr/mlSKcXO4teLq0kgPukmzyg9Q3+5r N/KnZwy3LasPLk/rfludu9HPhhG8u1EzAHIzVEEcR5pcUhe5bpq+c8OuqwC4neoecH nqzNBTsPrbF3A== Received: from alfajor (104-222-123-223.cpe.teksavvy.com [104.222.123.223]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id 7A315120314; Tue, 17 Sep 2019 15:12:29 -0400 (EDT) From: Stefan Monnier Message-ID: References: <5d810f73.1c69fb81.486b.2e0a@mx.google.com> Date: Tue, 17 Sep 2019 15:12:28 -0400 In-Reply-To: <5d810f73.1c69fb81.486b.2e0a@mx.google.com> ("Simen \=\?windows-1252\?Q\?Heggest\=F8yl\=22's\?\= message of "Tue, 17 Sep 2019 18:53:06 +0200") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.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.196 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: 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 (-) >> Of the whole file? No: instead you'd only use the max of the columns that >> you've seen so far. When it increases (thus invalidating >> alignment-overlays already created), you just "flush" those overlays and >> rebuild them. > Wouldn't then the columns appear to jump about whenever a new max width > is discovered? Yes, but that should only happen as part of a scroll or similar "significant" visual change anyway. > I also guess you'd lose the ability to do e.g. > C-u 1000 C-n and stay in the same column? Probably, yes. Seems like a minor issue to me. >> Maybe we could get yet more speedup by making it possible to pass to >> `current-column` (or a new C function) a start position along with its >> column, so we'd avoid re-traversing the part of the line that we've >> already processed. > I think that sounds like a good idea; then my ugly "fast-current-column" > Could this track be something worth exploring further? Your call, Stefan From unknown Mon Aug 18 11:27:46 2025 X-Loop: help-debbugs@gnu.org Subject: bug#37393: 26.2.90; [PATCH] Speed up 'csv-align-fields' Resent-From: Stefan Monnier Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 17 Sep 2019 19:15:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 37393 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch To: Eli Zaretskii Cc: 37393@debbugs.gnu.org, Simen =?UTF-8?Q?Heggest=C3=B8yl?= , sdl.web@gmail.com Received: via spool by 37393-submit@debbugs.gnu.org id=B37393.156874769516802 (code B ref 37393); Tue, 17 Sep 2019 19:15:02 +0000 Received: (at 37393) by debbugs.gnu.org; 17 Sep 2019 19:14:55 +0000 Received: from localhost ([127.0.0.1]:53301 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1iAIwB-0004Mt-0y for submit@debbugs.gnu.org; Tue, 17 Sep 2019 15:14:55 -0400 Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:59733) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1iAIw9-0004ML-He for 37393@debbugs.gnu.org; Tue, 17 Sep 2019 15:14:53 -0400 Received: from pmg1.iro.umontreal.ca (localhost.localdomain [127.0.0.1]) by pmg1.iro.umontreal.ca (Proxmox) with ESMTP id 5220E100D1F; Tue, 17 Sep 2019 15:14:48 -0400 (EDT) Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg1.iro.umontreal.ca (Proxmox) with ESMTP id 3B8EA100C6D; Tue, 17 Sep 2019 15:14:46 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1568747686; bh=GmVvE90bYrDbekAc6VHH9+IPyS8AqEOZuFYtwSveooQ=; h=From:To:Cc:Subject:References:Date:In-Reply-To:From; b=Ayxq6sLHH+4gnbaE/VggZ8F5NSTKLta+JXu4OWUs8q9S4cpuUz3/NIMXDYp4JGsKt 9PsBb461N+KNl+UiJUocmYXE40NtOCnX+fGLr0u79ATSQMIZMDiJV6BdXAV85tY0fU hWh6nhJymDCLSqDQKjVfHmOqNX33MCUfydJJpNTnP5jhfoyDJKxdQjchQlvkc3AL+4 kkOD7huksXBzcyp2UPm1pQUXuVGtEQBK5EjrTPVEFe9P22IAtJc2nsVwAbxSHwzdxj lLawVKHfJgdTqLlCog151GSfWqQ8SIWONabRO5zQDGmGrJJuCepvYWiiaunmwlg0LB fP9AuqDJ5pcyg== Received: from alfajor (104-222-123-223.cpe.teksavvy.com [104.222.123.223]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id C849D1203A9; Tue, 17 Sep 2019 15:14:45 -0400 (EDT) From: Stefan Monnier Message-ID: References: <5d810f73.1c69fb81.486b.2e0a@mx.google.com> <83r24evnug.fsf@gnu.org> Date: Tue, 17 Sep 2019 15:14:45 -0400 In-Reply-To: <83r24evnug.fsf@gnu.org> (Eli Zaretskii's message of "Tue, 17 Sep 2019 20:23:19 +0300") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.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.193 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: 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 (-) > Once again, risking to talk about something I don't clearly > understand: vertical-motion already allows you to pass an argument > which tells what is the current column. > Any rationale to use current-column instead of vertical-motion? But we need to measure the width of a particular chunk of buffer text, and I don't see how vertical-motion can be used for that: the only things it returns are: - a new point position - the number of screen lines moved over I can't see how to use it to compute the text's width. Stefan From unknown Mon Aug 18 11:27:46 2025 X-Loop: help-debbugs@gnu.org Subject: bug#37393: 26.2.90; [PATCH] Speed up 'csv-align-fields' Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 18 Sep 2019 02:36:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 37393 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch To: Stefan Monnier Cc: 37393@debbugs.gnu.org, simenheg@gmail.com, sdl.web@gmail.com Received: via spool by 37393-submit@debbugs.gnu.org id=B37393.156877410231881 (code B ref 37393); Wed, 18 Sep 2019 02:36:02 +0000 Received: (at 37393) by debbugs.gnu.org; 18 Sep 2019 02:35:02 +0000 Received: from localhost ([127.0.0.1]:53453 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1iAPo6-0008I8-4m for submit@debbugs.gnu.org; Tue, 17 Sep 2019 22:35:02 -0400 Received: from eggs.gnu.org ([209.51.188.92]:60742) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1iAPo3-0008HZ-KR for 37393@debbugs.gnu.org; Tue, 17 Sep 2019 22:35:00 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]:52470) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1iAPnx-00032W-CT; Tue, 17 Sep 2019 22:34:53 -0400 Received: from [176.228.60.248] (port=4844 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1iAPnw-0004Gs-MP; Tue, 17 Sep 2019 22:34:53 -0400 Date: Wed, 18 Sep 2019 05:34:52 +0300 Message-Id: <83o8ziuyb7.fsf@gnu.org> From: Eli Zaretskii In-reply-to: (message from Stefan Monnier on Tue, 17 Sep 2019 15:14:45 -0400) References: <5d810f73.1c69fb81.486b.2e0a@mx.google.com> <83r24evnug.fsf@gnu.org> MIME-version: 1.0 Content-type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] 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: Stefan Monnier > Cc: Simen Heggestøyl , > 37393@debbugs.gnu.org, > sdl.web@gmail.com > Date: Tue, 17 Sep 2019 15:14:45 -0400 > > > Once again, risking to talk about something I don't clearly > > understand: vertical-motion already allows you to pass an argument > > which tells what is the current column. > > Any rationale to use current-column instead of vertical-motion? > > But we need to measure the width of a particular chunk of buffer text, > and I don't see how vertical-motion can be used for that: the only > things it returns are: > - a new point position > - the number of screen lines moved over > I can't see how to use it to compute the text's width. What about posn-at-point? From unknown Mon Aug 18 11:27:46 2025 X-Loop: help-debbugs@gnu.org Subject: bug#37393: 26.2.90; [PATCH] Speed up 'csv-align-fields' References: <5d7a7b56.1c69fb81.c32f6.840d@mx.google.com> Resent-From: Simen =?UTF-8?Q?Heggest=C3=B8yl?= Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 18 Sep 2019 20:00:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 37393 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch To: Eli Zaretskii Cc: 37393@debbugs.gnu.org, monnier@iro.umontreal.ca, sdl.web@gmail.com Received: via spool by 37393-submit@debbugs.gnu.org id=B37393.156883677022002 (code B ref 37393); Wed, 18 Sep 2019 20:00:02 +0000 Received: (at 37393) by debbugs.gnu.org; 18 Sep 2019 19:59:30 +0000 Received: from localhost ([127.0.0.1]:54865 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1iAg6s-0005io-JT for submit@debbugs.gnu.org; Wed, 18 Sep 2019 15:59:30 -0400 Received: from mail-lf1-f67.google.com ([209.85.167.67]:35466) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1iAg6q-0005iY-4z for 37393@debbugs.gnu.org; Wed, 18 Sep 2019 15:59:28 -0400 Received: by mail-lf1-f67.google.com with SMTP id w6so591468lfl.2 for <37393@debbugs.gnu.org>; Wed, 18 Sep 2019 12:59:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=message-id:from:to:cc:subject:in-reply-to:date:mime-version; bh=QyFyLCrJRxFbPJBFk47udred3NFu3tGpaY9AF4u7r7A=; b=hVq7otV21kF5zSyVyN5kr1v9uYehbPzDfFXqKkG2JidBV4CK55uNKbFQgD8AKjWj76 0dkrDdlxFkD8eBACj5iK0Y45lA1FoOouIovPPNvEOhPZiCfhJNdOtcHsXXHxXdkTi6N5 jTJ8kKkM+6Fc3ui6BAVYY/9N8nR3brZPC2bhrVy9OX2D0rQMI5kHyyv51yT2b5i6hNQu Z9xScE8FgZtKbXg3s+T3NKqa5dmtUyBCrxAuDWzwvtr5XfdaQgO00RrWLxW5uVV9WXSW fIPk8Lf14TgdJLLl6nke5gLeQrvb6yBnKSE12Uj30KW0pIi1RBkiulxCjSiDUNo4kXGV PKUA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:message-id:from:to:cc:subject:in-reply-to:date :mime-version; bh=QyFyLCrJRxFbPJBFk47udred3NFu3tGpaY9AF4u7r7A=; b=T8D1YrfAhjwDI9H4xbFy8P+Ey47IlWwTDHVMgTGVhl+EDy4v9E5PWa+JdOI58bqFXV d3pjFeb6YI8s7y8SWWaEj2T66m3ezeTTf22MqyhTLhaTxAmDaBCtl5eCpqUTzv49u5cH JNSOl2qO9FB8Gnn6XXhvFIcQzz25cfhrgamAH7tqygehaiWDaXeUy87189FLOgjm7QNp TD38NzZpPtt2agkZlc98N1TrDWb3p5yu4UmMwLsj/h7c89WJ8SPWpAafDUyhSwDzhuyC bWXI7mgn16dFcAPBF7Tsa2hGs+AV6LEwuag119RmeeCJdrpZOdQomt8awEsmuFB+K6PC UAVw== X-Gm-Message-State: APjAAAWI/GDaWvo0gAv13B89NJquccaqs0O4cy60jDfMARtR95z5eUBN vJAdOKka6EPX4tRybA7Tu5w= X-Google-Smtp-Source: APXvYqwAP+5Zc2LqZNA5sq766584/0N/IDWH2QZ4EUr8IZzW5ybIVD9eZJFDgJmPilwjhZ8RrDRZCw== X-Received: by 2002:ac2:483a:: with SMTP id 26mr2920000lft.188.1568836762045; Wed, 18 Sep 2019 12:59:22 -0700 (PDT) Received: from ae25 (cm-84.210.143.4.getinternet.no. [84.210.143.4]) by smtp.gmail.com with ESMTPSA id f21sm1359031lfm.90.2019.09.18.12.59.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 Sep 2019 12:59:21 -0700 (PDT) Message-ID: <5d828c99.1c69fb81.1ec00.8239@mx.google.com> X-Google-Original-Message-ID: <875zlpfk9z.fsf@simenheg@gmail.com> From: Simen =?UTF-8?Q?Heggest=C3=B8yl?= In-Reply-To: <83o8ziuyb7.fsf@gnu.org> (message from Eli Zaretskii on Wed, 18 Sep 2019 05:34:52 +0300) Date: Wed, 18 Sep 2019 21:59:20 +0200 MIME-Version: 1.0 Content-Type: text/plain 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: > What about posn-at-point? That one doesn't seem to take the display width of the characters into account. For instance, in a buffer with "" and point at the end, 'current-column' returns column 9 as expected, while 'posn-at-point' gives 3. -- Simen From unknown Mon Aug 18 11:27:46 2025 X-Loop: help-debbugs@gnu.org Subject: bug#37393: 26.2.90; [PATCH] Speed up 'csv-align-fields' Resent-From: Stefan Monnier Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 18 Sep 2019 20:09:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 37393 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch To: Simen =?UTF-8?Q?Heggest=C3=B8yl?= Cc: Eli Zaretskii , 37393@debbugs.gnu.org, sdl.web@gmail.com Received: via spool by 37393-submit@debbugs.gnu.org id=B37393.156883731922965 (code B ref 37393); Wed, 18 Sep 2019 20:09:02 +0000 Received: (at 37393) by debbugs.gnu.org; 18 Sep 2019 20:08:39 +0000 Received: from localhost ([127.0.0.1]:54874 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1iAgFh-0005yI-FU for submit@debbugs.gnu.org; Wed, 18 Sep 2019 16:08:39 -0400 Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:34619) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1iAgFf-0005xz-45 for 37393@debbugs.gnu.org; Wed, 18 Sep 2019 16:08:35 -0400 Received: from pmg3.iro.umontreal.ca (localhost [127.0.0.1]) by pmg3.iro.umontreal.ca (Proxmox) with ESMTP id BF10C447F92; Wed, 18 Sep 2019 16:08:29 -0400 (EDT) Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg3.iro.umontreal.ca (Proxmox) with ESMTP id 66EDC447F3D; Wed, 18 Sep 2019 16:08:28 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1568837308; bh=tEBPVLSaSoi0nVqWnG19TO4m/bWc8Zf/2P/1lsIAB4w=; h=From:To:Cc:Subject:References:Date:In-Reply-To:From; b=TzAI304wb0H2s7pHw+hDtFFmvuM0+boi43wpKtkYx1QB/f88pWiDuyen+n7BzE0FZ cSBtT+0FvBHoWARfcSSNbXcm/cl43cXaBPR++WI6AXpLGHF5kROXrQW+Pg/ngdcqvW gyD3LPiKS7rUH6aEfxoqNSioXJi5vS+pOZi8wDFiVKZaps5NfOPCT+v051X78cFJAh pXNCYw569pm4WmuzZzIKesqAcwhUYHm57FlOattu/5kwKnAOSrlgBPqw3njZ1o1K1X ridlvw0dn0Gsii5YySp6tSibm7TTF/pEN7Li552jP5Q5jPvPFXJl081gSe8ex9ssKk ZsKjCfFFAnVxg== Received: from lechazo (lechon.iro.umontreal.ca [132.204.27.242]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id 415EF12044D; Wed, 18 Sep 2019 16:08:28 -0400 (EDT) From: Stefan Monnier Message-ID: References: <5d828c99.1c69fb81.1ec00.8239@mx.google.com> Date: Wed, 18 Sep 2019 16:08:27 -0400 In-Reply-To: <5d828c99.1c69fb81.1ec00.8239@mx.google.com> ("Simen \=\?windows-1252\?Q\?Heggest\=F8yl\=22's\?\= message of "Wed, 18 Sep 2019 21:59:20 +0200") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.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: 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 (-) >> What about posn-at-point? > That one doesn't seem to take the display width of the characters into > account. For instance, in a buffer with "" and point > at the end, 'current-column' returns column 9 as expected, while > 'posn-at-point' gives 3. It should return a lot more information than just a bare number. I suspect you did not look at the right number. I think you'd have to use the pixel (X . Y) information (and divide it by the frame's char width), rather than the (COL . ROW) one. Stefan From unknown Mon Aug 18 11:27:46 2025 X-Loop: help-debbugs@gnu.org Subject: bug#37393: 26.2.90; [PATCH] Speed up 'csv-align-fields' References: <5d7a7b56.1c69fb81.c32f6.840d@mx.google.com> Resent-From: Simen =?UTF-8?Q?Heggest=C3=B8yl?= Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 19 Sep 2019 15:52:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 37393 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch To: Stefan Monnier Cc: eliz@gnu.org, 37393@debbugs.gnu.org, sdl.web@gmail.com Received: via spool by 37393-submit@debbugs.gnu.org id=B37393.15689083025718 (code B ref 37393); Thu, 19 Sep 2019 15:52:02 +0000 Received: (at 37393) by debbugs.gnu.org; 19 Sep 2019 15:51:42 +0000 Received: from localhost ([127.0.0.1]:56298 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1iAyic-0001U7-3o for submit@debbugs.gnu.org; Thu, 19 Sep 2019 11:51:42 -0400 Received: from mail-lj1-f179.google.com ([209.85.208.179]:36611) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1iAyia-0001Ts-IJ for 37393@debbugs.gnu.org; Thu, 19 Sep 2019 11:51:41 -0400 Received: by mail-lj1-f179.google.com with SMTP id v24so4133756ljj.3 for <37393@debbugs.gnu.org>; Thu, 19 Sep 2019 08:51:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=message-id:from:to:cc:subject:in-reply-to:date:mime-version; bh=NNrzNIzkFSo8Eu/rIre0dLUKZ/QsbRPV//c7aDuIjh8=; b=ataIGxO3zXd5QYEcPP3Sfczkt1C7VbOcD7IQ3PZGi/4YkGVlNyksWyvaXTG4xI7PLv p0Ikp0QEWe4Tjp6TGj8QYAJIZRH0YDhfz51Z8OzjRv4ThGpNLeAP50wXBwb1VIp+2jyK no+pjV3pTGTf/F1iHcobdK3MV3Tt3iltzFNAHmjiSFWGGr/hnHbW/u9faz7KoDxrcbdH btkLiLLT3IHcN50UK83hVPpAAvRK+g+pkUrKJayofHvK2rLd/EsPyaTMFAwEblgOkJTr g410w6Jy43oeJfmjxMD0qXToVMX3XnfTHRley17R9iB9RU88LbepjT26zu6VMrbaPGGV dZYQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:message-id:from:to:cc:subject:in-reply-to:date :mime-version; bh=NNrzNIzkFSo8Eu/rIre0dLUKZ/QsbRPV//c7aDuIjh8=; b=RYEToZj9KoAUJCdmgFfzQ+ylTH/BY31hnVMvB1BBAO1CUggokmhRsl4urv87FLB89/ 6EXiJktRQ7TBYUld1jc0iTOj0tZhhnNT6PCSR44hwVL/Ty5nuf4T9ujTAYETjdty/R2e qb4WheT263s1ryX5/HRXJ4Crg2mUsN4e9aKzpplNFSINTUTrzzrSJayQUpy6MVFOOnhx nENh5kpXNB1ZQb8Bc8yylofY0wdQxoISUNt3Ar/0EI1hFG68KCuoeM8nR47mBIs+eYkQ vNy4T5lYXkqWLm8wrfkA8ie2OPxlD2rYrHVUzI/yjmXas4YulfNb3qz5+pCd20FuwREg Mj/g== X-Gm-Message-State: APjAAAUEkkxAdnkAAZ72UyncpOYxlQOdt77tsmdTKN13MO/VLSOOE86t wd/bnIK0ZAjmOkmppWQHz+U= X-Google-Smtp-Source: APXvYqw3UnVlXoMlbpnlo/Q/6zPZhSv7VJo7gZfzFa8EqG6hshPchEExhhF+MnGG+BRGhDcnavl9IA== X-Received: by 2002:a2e:9d0d:: with SMTP id t13mr5760913lji.169.1568908294515; Thu, 19 Sep 2019 08:51:34 -0700 (PDT) Received: from ae25 (cm-84.210.143.4.getinternet.no. [84.210.143.4]) by smtp.gmail.com with ESMTPSA id i21sm1649675lfl.44.2019.09.19.08.51.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Sep 2019 08:51:34 -0700 (PDT) Message-ID: <5d83a406.1c69fb81.2333f.938a@mx.google.com> X-Google-Original-Message-ID: <87ef0c1dyy.fsf@simenheg@gmail.com> From: Simen =?UTF-8?Q?Heggest=C3=B8yl?= In-Reply-To: (message from Stefan Monnier on Wed, 18 Sep 2019 16:08:27 -0400) Date: Thu, 19 Sep 2019 17:51:33 +0200 MIME-Version: 1.0 Content-Type: text/plain 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: > It should return a lot more information than just a bare number. > I suspect you did not look at the right number. I think you'd have to > use the pixel (X . Y) information (and divide it by the frame's char > width), rather than the (COL . ROW) one. Your suspicion is correct, I looked at the COL field. By using the pixel X divided by (frame-char-width), the results look right, but I'm getting a slowdown on a 400 line file from 0.03s to 2s. -- Simen From unknown Mon Aug 18 11:27:46 2025 X-Loop: help-debbugs@gnu.org Subject: bug#37393: 26.2.90; [PATCH] Speed up 'csv-align-fields' Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 19 Sep 2019 17:31:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 37393 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch To: Simen =?UTF-8?Q?Heggest=C3=B8yl?= Cc: 37393@debbugs.gnu.org, monnier@iro.umontreal.ca, sdl.web@gmail.com Received: via spool by 37393-submit@debbugs.gnu.org id=B37393.156891422617472 (code B ref 37393); Thu, 19 Sep 2019 17:31:01 +0000 Received: (at 37393) by debbugs.gnu.org; 19 Sep 2019 17:30:26 +0000 Received: from localhost ([127.0.0.1]:56370 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1iB0G9-0004Xk-NW for submit@debbugs.gnu.org; Thu, 19 Sep 2019 13:30:25 -0400 Received: from eggs.gnu.org ([209.51.188.92]:43355) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1iB0G7-0004XT-BL for 37393@debbugs.gnu.org; Thu, 19 Sep 2019 13:30:23 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]:53907) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1iB0G1-0005UW-Lw; Thu, 19 Sep 2019 13:30:17 -0400 Received: from [176.228.60.248] (port=4685 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1iB0Fz-0001sG-1u; Thu, 19 Sep 2019 13:30:17 -0400 Date: Thu, 19 Sep 2019 20:30:16 +0300 Message-Id: <83impotcrb.fsf@gnu.org> From: Eli Zaretskii In-reply-to: <5d83a406.1c69fb81.2333f.938a@mx.google.com> (message from Simen =?UTF-8?Q?Heggest=C3=B8yl?= on Thu, 19 Sep 2019 17:51:33 +0200) References: <5d83a406.1c69fb81.2333f.938a@mx.google.com> MIME-version: 1.0 Content-type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] 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: Simen Heggestøyl > Cc: eliz@gnu.org, 37393@debbugs.gnu.org, sdl.web@gmail.com > Date: Thu, 19 Sep 2019 17:51:33 +0200 > > By using the pixel X divided by (frame-char-width), the results look > right, but I'm getting a slowdown on a 400 line file from 0.03s to 2s. Then I guess this technique won't help in your case. Sorry for distracting you. From unknown Mon Aug 18 11:27:46 2025 MIME-Version: 1.0 X-Mailer: MIME-tools 5.505 (Entity 5.505) X-Loop: help-debbugs@gnu.org From: help-debbugs@gnu.org (GNU bug Tracking System) To: Simen =?UTF-8?Q?Heggest=C3=B8yl?= Subject: bug#37393: closed (Re: 26.2.90; [PATCH] Speed up 'csv-align-fields') Message-ID: References: <5d9e0bcd.1c69fb81.243b2.2d05@mx.google.com> <5d7a7b56.1c69fb81.c32f6.840d@mx.google.com> X-Gnu-PR-Message: they-closed 37393 X-Gnu-PR-Package: emacs X-Gnu-PR-Keywords: patch Reply-To: 37393@debbugs.gnu.org Date: Wed, 09 Oct 2019 16:34:02 +0000 Content-Type: multipart/mixed; boundary="----------=_1570638842-30796-1" This is a multi-part message in MIME format... ------------=_1570638842-30796-1 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Your bug report #37393: 26.2.90; [PATCH] Speed up 'csv-align-fields' which was filed against the emacs package, has been closed. The explanation is attached below, along with your original report. If you require more details, please reply to 37393@debbugs.gnu.org. --=20 37393: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=3D37393 GNU Bug Tracking System Contact help-debbugs@gnu.org with problems ------------=_1570638842-30796-1 Content-Type: message/rfc822 Content-Disposition: inline Content-Transfer-Encoding: 7bit Received: (at 37393-done) by debbugs.gnu.org; 9 Oct 2019 16:33:25 +0000 Received: from localhost ([127.0.0.1]:53920 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1iIEtx-0007zW-9f for submit@debbugs.gnu.org; Wed, 09 Oct 2019 12:33:25 -0400 Received: from mail-lj1-f171.google.com ([209.85.208.171]:43279) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1iIEtw-0007zH-AG for 37393-done@debbugs.gnu.org; Wed, 09 Oct 2019 12:33:24 -0400 Received: by mail-lj1-f171.google.com with SMTP id n14so3131162ljj.10 for <37393-done@debbugs.gnu.org>; Wed, 09 Oct 2019 09:33:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=message-id:from:to:cc:subject:in-reply-to:date:mime-version; bh=U7YW59EnjlWBpCKLvHQRxZs4czHqVBGmL4s+oiuWkTA=; b=YL56jVYAmWL7B3NTJQ6ImZboKugBF3iLxU7MWvl2LJSue7iNx3A/KIhwO5rzE0oKhQ LMGGnLxJsI+vbM786JCGF8pw3Jzl+r9+rH9WAYH4gifAyL92inTTI/ekhdUv8N5x7nrE +3x7i0OQiQOWJF9GL2qllCKVcph0WNUYREIYLYSZ2PCjunPyDX3WzPk78e+e2TFVjP9e kbgzYm/n0RaGF6kYmvBdW2jRHMsTQMe9BLCmtWIRGEp1bZUzjO3iAEf5QZgyICv6R1dF Dt7hsmKJZx7LWpw6TJaoD2ithbCnnePdC0Qtk92MH8IGaBKGq+4+IpJ/dNpqeJ7nCPy1 c+8A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:message-id:from:to:cc:subject:in-reply-to:date :mime-version; bh=U7YW59EnjlWBpCKLvHQRxZs4czHqVBGmL4s+oiuWkTA=; b=c6Sm5AgDRWEaTRSpqGh3v69iCgh41/G5S6priki2tGbo9muOMIAGok5OrOQBI4r4dr MdJ0mYxFIkUW21bg306HrmC6MtzvmE2hHh3qUxiNBO4n4kAb4x8tRTIaSqsAH82obAYj uXtQdEO10U21ldW4mR8cnESn939pvqANaR75fI0PN1CmLHpATJTL7MmcpOKw+JFkgnO4 /uBNB3qkA07CQeUdCAUCsS1PmMuudpV30aDY1+1X+/JL6vf/sSxoZWlGi7SeP62daFC1 TKzSptgcieIJq9xHU1EtfMPtVlrDe7j7RJKGqj41dbfU8kP8Fhm1yz7MzNircnvran1H Zr/g== X-Gm-Message-State: APjAAAVo/UKxvQFropvDbu9/av/RF4JUvBjTbqd9RQBD/teE3vBjCf+f wXA3hUiNEiLYxMzXUFepxFM= X-Google-Smtp-Source: APXvYqx293uMXZC6K/nS6kLVE64pMzwr6xv7gWStOVcQUYsbkoIaIxfvsWxhrtlf26M7SlGAxCBgQQ== X-Received: by 2002:a2e:6348:: with SMTP id x69mr3014326ljb.200.1570638798127; Wed, 09 Oct 2019 09:33:18 -0700 (PDT) Received: from ae25 (cm-84.210.143.4.getinternet.no. [84.210.143.4]) by smtp.gmail.com with ESMTPSA id y206sm600336lfc.6.2019.10.09.09.33.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 09 Oct 2019 09:33:17 -0700 (PDT) Message-ID: <5d9e0bcd.1c69fb81.243b2.2d05@mx.google.com> X-Google-Original-Message-ID: <87tv8hg9pv.fsf@simenheg@gmail.com> From: =?utf-8?Q?Simen_Heggest=C3=B8yl?= To: Eli Zaretskii Subject: Re: 26.2.90; [PATCH] Speed up 'csv-align-fields' In-Reply-To: <83impotcrb.fsf@gnu.org> (message from Eli Zaretskii on Thu, 19 Sep 2019 20:30:16 +0300) Date: Wed, 09 Oct 2019 18:33:16 +0200 MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 37393-done Cc: 37393-done@debbugs.gnu.org, monnier@iro.umontreal.ca, sdl.web@gmail.com 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: > Then I guess this technique won't help in your case. Sorry for > distracting you. No problem, thanks the suggestions. Closing this bug now as the original patch has been installed (with some changes suggested by Stefan). -- Simen ------------=_1570638842-30796-1 Content-Type: message/rfc822 Content-Disposition: inline Content-Transfer-Encoding: 7bit Received: (at submit) by debbugs.gnu.org; 12 Sep 2019 17:07:43 +0000 Received: from localhost ([127.0.0.1]:44065 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1i8SZK-0000mS-GA for submit@debbugs.gnu.org; Thu, 12 Sep 2019 13:07:42 -0400 Received: from lists.gnu.org ([209.51.188.17]:53341) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1i8SZJ-0000mL-97 for submit@debbugs.gnu.org; Thu, 12 Sep 2019 13:07:41 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:39005) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i8SZH-0004Ty-Tl for bug-gnu-emacs@gnu.org; Thu, 12 Sep 2019 13:07:41 -0400 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: ** X-Spam-Status: No, score=2.8 required=5.0 tests=BAYES_50,FREEMAIL_FROM, SPOOFED_FREEMAIL,URIBL_BLOCKED autolearn=disabled version=3.3.2 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1i8SZG-0005lW-7O for bug-gnu-emacs@gnu.org; Thu, 12 Sep 2019 13:07:39 -0400 Received: from mail-lj1-x22a.google.com ([2a00:1450:4864:20::22a]:40530) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1i8SZF-0005l3-UI for bug-gnu-emacs@gnu.org; Thu, 12 Sep 2019 13:07:38 -0400 Received: by mail-lj1-x22a.google.com with SMTP id 7so24306078ljw.7 for ; Thu, 12 Sep 2019 10:07:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=message-id:from:to:cc:subject:date:mime-version; bh=DYs8gJwEU+28u6199VOZSBEJ4TNRDlFnrJv94Er/8WU=; b=HE8rD5zHChKkQP5K7mPJUyPLb4RWS5sHhsaQKirQokaGkTz/Ic1ooaHaqwQOVXw0MP MMSvHBr7/lUL32PGp3KDp8fC4KqsuBmbEnlxsZOFj90BxIbKJTEfEB35kCTA9NpAxXPK q8h9QemrrNr16bXfafzwghLgGWm6rDuTEd9EB1/NmNn81qlB67/cq+nsCmUGxT/h5/aX 82EyLKv1ORMZtuHTDxnKoWepau2YVbEooKeBVh9QvryITDmhxLJ8k3OqwE5bvxhtKSdb Q0m+OfgtJliJ16WodUkRYZ1cmmKcmh2l+RiUPGPl0SD5SZem9E5IFstUUBL/zACCNynR PUpg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:message-id:from:to:cc:subject:date:mime-version; bh=DYs8gJwEU+28u6199VOZSBEJ4TNRDlFnrJv94Er/8WU=; b=O0NTfuov92aF7RuMUfWC3aTOnbVJEVQQUqRgP6VJ4zFt/MEPh4b5BDAZqB+BO0SxMm +Cf61rT936RjTf7+aqbzmORGlMjDfoIszV9YHJ3nWJ5ISGrgnFPwkuDsZrfgYWrzehRe X+nnutH0ezl7cK5Psrn06DUMqPArs7/7sbx4JhXEsezvnHf9Kvx0YuSavZW5KDSM8+ks rNkyQ/Ug+4ADm4uBa4CsWQcW1AIyMRXD/0tBg/ApjN0wXZZLedddRTG3ysqUZ0OGW42O kGLKJyrvlNpuOeQTH52JK5fMnODj26sXosY24pA4oMQkmokPJaek7rSckRrM+xFdB8Xm 1mMQ== X-Gm-Message-State: APjAAAVktcDyoRm3MJmFwSnYuw9BiUhltgmoS6B677L7tsGna8Dm8tBK Q07tMcKC+unkU4RsyG57X4k= X-Google-Smtp-Source: APXvYqwAeGIfmabx3wq0hD4s2ick+1g1u56RRKX9/bN4bOwCnrk+t1kPsISFGmDt5ztgMkVqAsqSIQ== X-Received: by 2002:a2e:83d6:: with SMTP id s22mr27346168ljh.104.1568308055485; Thu, 12 Sep 2019 10:07:35 -0700 (PDT) Received: from ae25 (cm-84.210.143.4.getinternet.no. [84.210.143.4]) by smtp.gmail.com with ESMTPSA id v10sm5818211ljc.64.2019.09.12.10.07.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 Sep 2019 10:07:34 -0700 (PDT) Message-ID: <5d7a7b56.1c69fb81.c32f6.840d@mx.google.com> X-Google-Original-Message-ID: <87sgp1qw8a.fsf@simenheg@gmail.com> From: =?utf-8?Q?Simen_Heggest=C3=B8yl?= To: bug-gnu-emacs@gnu.org Subject: 26.2.90; [PATCH] Speed up 'csv-align-fields' Date: Thu, 12 Sep 2019 19:07:33 +0200 MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::22a X-Spam-Score: 0.7 (/) X-Debbugs-Envelope-To: submit Cc: Stefan Monnier , Leo Liu 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.3 (/) --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable The attached patch attempts to speed up the 'csv-align-fields' command by avoiding expensive calls to 'current-column', instead reusing field widths already computed by 'csv--column-widths'. I felt an urge to speed up the command a bit while working with large (100 000+ lines) CSV files. Below are benchmarks produced by running (benchmark 3 '(csv-align-fields nil (point-min) (point-max))) in three CSV files from the real world of various sizes. In these cases the speedup seems to be around 1.5x=E2=80=942x. ~400 line file: Before: Elapsed time: 0.175867s After: Elapsed time: 0.086809s ~50 000 line file: Before: Elapsed time: 34.665853s (7.480686s in 35 GCs) After: Elapsed time: 24.349081s (7.154716s in 27 GCs) ~110 000 line file: Before: Elapsed time: 82.444038s (19.799686s in 51 GCs) After: Elapsed time: 40.184331s (9.037813s in 25 GCs) (I've put on CC the two of you who seem to have done most of the work on this mode lately, hope that's OK.) -- Simen --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=0001-Speed-up-csv-align-fields.patch >From 4fc82f1f66c736bcfbc15d20ff53bd3e21e8a8e1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Simen=20Heggest=C3=B8yl?= Date: Thu, 12 Sep 2019 18:54:28 +0200 Subject: [PATCH] Speed up 'csv-align-fields' * packages/csv-mode/csv-mode.el: Bump version number and make the dependency on Emacs 24.1 or higher explicit. (csv--column-widths): Return the field widths as well. (csv-align-fields): Speed up by using the field widths already computed by 'csv--column-widths'. --- packages/csv-mode/csv-mode.el | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/packages/csv-mode/csv-mode.el b/packages/csv-mode/csv-mode.el index 40f70330a..dc2555687 100644 --- a/packages/csv-mode/csv-mode.el +++ b/packages/csv-mode/csv-mode.el @@ -4,7 +4,8 @@ ;; Author: "Francis J. Wright" ;; Time-stamp: <23 August 2004> -;; Version: 1.7 +;; Version: 1.8 +;; Package-Requires: ((emacs "24.1")) ;; Keywords: convenience ;; This package is free software; you can redistribute it and/or modify @@ -969,24 +970,26 @@ The fields yanked are those last killed by `csv-kill-fields'." (and (overlay-get o 'csv) (delete-overlay o))) (defun csv--column-widths () - (let ((widths '())) + (let ((column-widths '()) + (field-widths '())) ;; Construct list of column widths: (while (not (eobp)) ; for each record... (or (csv-not-looking-at-record) - (let ((w widths) + (let ((w column-widths) (col (current-column)) - x) + field-width) (while (not (eolp)) (csv-end-of-field) - (setq x (- (current-column) col)) ; Field width. + (setq field-width (- (current-column) col)) + (push field-width field-widths) (if w - (if (> x (car w)) (setcar w x)) - (setq w (list x) - widths (nconc widths w))) + (if (> field-width (car w)) (setcar w field-width)) + (setq w (list field-width) + column-widths (nconc column-widths w))) (or (eolp) (forward-char)) ; Skip separator. (setq w (cdr w) col (current-column))))) (forward-line)) - widths)) + (list column-widths (nreverse field-widths)))) (defun csv-align-fields (hard beg end) "Align all the fields in the region to form columns. @@ -1017,23 +1020,22 @@ If there is no selected region, default to the whole buffer." (narrow-to-region beg end) (set-marker end nil) (goto-char (point-min)) - (let ((widths (csv--column-widths))) + (pcase-let ((`(,column-widths ,field-widths) (csv--column-widths))) ;; Align fields: (goto-char (point-min)) (while (not (eobp)) ; for each record... (unless (csv-not-looking-at-record) - (let ((w widths) + (let ((w column-widths) (column 0)) ;Desired position of left-side of this column. (while (and w (not (eolp))) (let* ((beg (point)) (align-padding (if (bolp) 0 csv-align-padding)) (left-padding 0) (right-padding 0) - (field-width - (- (- (current-column) - (progn (csv-end-of-field) (current-column))))) + (field-width (pop field-widths)) (column-width (pop w)) (x (- column-width field-width))) ; Required padding. + (csv-end-of-field) (set-marker end (point)) ; End of current field. ;; beg = beginning of current field ;; end = (point) = end of current field -- 2.23.0 --=-=-=-- ------------=_1570638842-30796-1--