]> git.eshelyaron.com Git - emacs.git/commitdiff
Cheaper char counting when reading symbols
authorMattias EngdegÄrd <mattiase@acm.org>
Mon, 8 Jul 2024 08:58:32 +0000 (10:58 +0200)
committerEshel Yaron <me@eshelyaron.com>
Thu, 24 Jul 2025 07:49:10 +0000 (09:49 +0200)
* src/lread.c (read0): Strength reduction.

(cherry picked from commit c120a338e6ef15888338fbd499caf5c1c02777e4)

src/lread.c

index e714684f4c858e2c8b4ed5af598fa3f4160bd888..7f226074f094d90c909a31b29245d2b6fe689d1e 100644 (file)
@@ -4434,6 +4434,7 @@ read0 (Lisp_Object readcharfun, bool locate_syms)
        rb.cur = rb.start;
        bool quoted = false;
        EMACS_INT start_position = readchar_offset - 1;
+       ptrdiff_t nchars = 0;
 
        do
          {
@@ -4446,6 +4447,7 @@ read0 (Lisp_Object readcharfun, bool locate_syms)
              }
 
            add_char_to_buffer (&rb, c, multibyte);
+           nchars++;
            c = READCHAR;
          }
        while (c > 32
@@ -4474,10 +4476,6 @@ read0 (Lisp_Object readcharfun, bool locate_syms)
          }
 
        /* symbol, possibly uninterned */
-       ptrdiff_t nchars
-         = (multibyte
-            ? multibyte_chars_in_text ((unsigned char *)rb.start, nbytes)
-            : nbytes);
        Lisp_Object result;
        if (uninterned_symbol)
          {