diff options
| author | Mattias EngdegÄrd | 2024-02-07 21:50:03 +0100 |
|---|---|---|
| committer | Mattias EngdegÄrd | 2024-02-12 18:23:33 +0100 |
| commit | 79cfc1eaa0b93f49559d74b6f7a76bf97e70ad2a (patch) | |
| tree | d78ad60540e0ad974d5871a6bf9f7fadd850fed1 /src | |
| parent | 6aeeae68885e09a7253a0076d0f81cc46b37f20d (diff) | |
| download | emacs-79cfc1eaa0b93f49559d74b6f7a76bf97e70ad2a.tar.gz emacs-79cfc1eaa0b93f49559d74b6f7a76bf97e70ad2a.zip | |
Internal function for obarray performance analysis (bug#68244)
* src/lread.c (Finternal__obarray_buckets): New function.
Diffstat (limited to 'src')
| -rw-r--r-- | src/lread.c | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/src/lread.c b/src/lread.c index 5aa7466cc12..8f355547268 100644 --- a/src/lread.c +++ b/src/lread.c | |||
| @@ -5296,6 +5296,32 @@ OBARRAY defaults to the value of `obarray'. */) | |||
| 5296 | return Qnil; | 5296 | return Qnil; |
| 5297 | } | 5297 | } |
| 5298 | 5298 | ||
| 5299 | DEFUN ("internal--obarray-buckets", | ||
| 5300 | Finternal__obarray_buckets, Sinternal__obarray_buckets, 1, 1, 0, | ||
| 5301 | doc: /* Symbols in each bucket of OBARRAY. Internal use only. */) | ||
| 5302 | (Lisp_Object obarray) | ||
| 5303 | { | ||
| 5304 | obarray = check_obarray (obarray); | ||
| 5305 | ptrdiff_t size = ASIZE (obarray); | ||
| 5306 | Lisp_Object ret = Qnil; | ||
| 5307 | for (ptrdiff_t i = 0; i < size; i++) | ||
| 5308 | { | ||
| 5309 | Lisp_Object bucket = Qnil; | ||
| 5310 | Lisp_Object sym = AREF (obarray, i); | ||
| 5311 | if (BARE_SYMBOL_P (sym)) | ||
| 5312 | while (1) | ||
| 5313 | { | ||
| 5314 | bucket = Fcons (sym, bucket); | ||
| 5315 | struct Lisp_Symbol *s = XBARE_SYMBOL(sym)->u.s.next; | ||
| 5316 | if (!s) | ||
| 5317 | break; | ||
| 5318 | sym = make_lisp_symbol (s); | ||
| 5319 | } | ||
| 5320 | ret = Fcons (Fnreverse (bucket), ret); | ||
| 5321 | } | ||
| 5322 | return Fnreverse (ret); | ||
| 5323 | } | ||
| 5324 | |||
| 5299 | #define OBARRAY_SIZE 15121 | 5325 | #define OBARRAY_SIZE 15121 |
| 5300 | 5326 | ||
| 5301 | void | 5327 | void |
| @@ -5693,6 +5719,7 @@ syms_of_lread (void) | |||
| 5693 | defsubr (&Sget_file_char); | 5719 | defsubr (&Sget_file_char); |
| 5694 | defsubr (&Smapatoms); | 5720 | defsubr (&Smapatoms); |
| 5695 | defsubr (&Slocate_file_internal); | 5721 | defsubr (&Slocate_file_internal); |
| 5722 | defsubr (&Sinternal__obarray_buckets); | ||
| 5696 | 5723 | ||
| 5697 | DEFVAR_LISP ("obarray", Vobarray, | 5724 | DEFVAR_LISP ("obarray", Vobarray, |
| 5698 | doc: /* Symbol table for use by `intern' and `read'. | 5725 | doc: /* Symbol table for use by `intern' and `read'. |