emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

string_char_to_byte and string_byte_to_char micro-optimisation


From: Robert Pluim
Subject: string_char_to_byte and string_byte_to_char micro-optimisation
Date: Fri, 14 Jun 2019 14:37:58 +0200

Hi,

in <https://nullprogram.com/blog/2019/05/29/> a benchmark is shown:

(defun compare (string-a string-b)
  (cl-loop for a being the elements of string-a
           for b being the elements of string-b
           unless (eql a b)
           return (cons a b)))
(benchmark-run
    (let ((a (make-string 100000 0))
          (b (make-string 100000 0)))
      (setf (aref a (1- (length a))) 256
            (aref b (1- (length b))) 256)
      (compare a b)))

which runs very slowly because string_char_to_byte and
string_byte_to_char only cache the found values for 1 previous string.

I have a patch which extends this cache to two (count 'em, two!)
previous strings, which fixes this particular benchmark.

What I donʼt have is any intuition on whether such a change actually
makes any difference in real-world Emacs usage. Can anyone suggest any
benchmarks?

Thanks

Robert



reply via email to

[Prev in Thread] Current Thread [Next in Thread]