I have some code using (looking-back … (line-beginning-position))
. Doc string of looking-back
states that it's better to avoid this function because of slowness. I'm curious will following approach be faster?
(save-excursion
(goto-char (line-beginning-position))
(looking-at regexp stuff))
looking-at
version easily. Thank you.(with-temp-buffer (insert (make-string 10000 ?x)) (looking-back "y"))
You'll see it is very fast. Now change the regexp to".*y"
instead : it's unbearably slow even though it's clear to the human reader that this can never match.