[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [AUCTeX] A problem with \parencite and fill-paragraph
From: |
Arash Esbati |
Subject: |
Re: [AUCTeX] A problem with \parencite and fill-paragraph |
Date: |
Fri, 31 Mar 2017 09:38:23 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/25.2 |
Mosè Giordano <address@hidden> writes:
> I think we all came up with similar solutions. I was concerned about
> performance of Arash's fix, but according to `benchmark-run' the
> overhead isn't large (slowdown of the order of few percents) and
> shouldn't be noticeable in normal situations.
Hi Mosè,
thanks for looking at it. I think I can tweak the function to get
faster by increasing `gc-cons-threshold' and changing the string-match
condition. Here is what I get with /1 as my original suggestion and /2
the new one. Do you also want to give it a roll?
--8<---------------cut here---------------start------------->8---
(defun LaTeX-paragraph-commands-regexp-make/1 ()
"Return a regular expression matching defined paragraph commands."
(let (cmds symbs)
(dolist (mac (append LaTeX-paragraph-commands
LaTeX-paragraph-commands-internal))
(if (string-match "[a-zA-Z]" mac)
(push mac cmds)
(push mac symbs)))
(concat (regexp-quote TeX-esc) "\\("
(regexp-opt cmds)
"\\b"
"\\|"
(regexp-opt symbs)
"\\B"
"\\)")))
(defun LaTeX-paragraph-commands-regexp-make/2 ()
"Return a regular expression matching defined paragraph commands."
(let ((gc-cons-threshold most-positive-fixnum)
cmds symbs)
(dolist (mac (append LaTeX-paragraph-commands
LaTeX-paragraph-commands-internal))
(if (string-match "[^a-zA-Z]" mac)
(push mac symbs)
(push mac cmds)))
(concat (regexp-quote TeX-esc) "\\("
(regexp-opt cmds)
"\\b"
"\\|"
(regexp-opt symbs)
"\\B"
"\\)")))
(benchmark-run 10000 (LaTeX-paragraph-commands-regexp-make))
(benchmark-run 10000 (LaTeX-paragraph-commands-regexp-make/1))
(benchmark-run 10000 (LaTeX-paragraph-commands-regexp-make/2))
Results:
Original: (1.8593714000000001 135 1.421876200000007)
/1: (1.9218724 133 1.421879200000003)
/2 (w/o gc-tweak): (1.8749965 133 1.406252999999996)
Original: (1.8281209 133 1.3437572999999858)
/1: (1.9062489999999999 132 1.4375054999999968)
/2 (w/ gc-tweak): (1.8437484 131 1.3750041000000017)
--8<---------------cut here---------------end--------------->8---
> Arash, if you're going to install your patch, please add also a test.
> I know that writing tests is one of the most annoying part of coding,
> yet it's very important because it ensures that we won't break
> something again in the future.
I will wait a day to see if Keita has another suggestion, then will
install a patch. I'm easy with adding a test, will think about a proper
test case.
Best, Arash