summaryrefslogtreecommitdiff
path: root/lisp/emacs-lisp/byte-opt.el
Commit message (Collapse)AuthorAgeFilesLines
...
* | Move side-effect-free and pure declarations to function definitionsMattias Engdegård2023-02-171-33/+24
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Some Lisp functions still had their `side-effect-free` and `pure` properties declared in byte-opt.el; do it at their definition instead. The lists in byte-opt.el now only contain functions implemented in C and function aliases. * lisp/emacs-lisp/byte-opt.el (side-effect-free-fns) (side-effect-and-error-free-fns, pure-fns): Remove functions whose properties are now declared elsewhere and some obsolete entries. * lisp/custom.el (custom-variable-p): * lisp/emacs-lisp/lisp.el (buffer-end): * lisp/emacs-lisp/regexp-opt.el (regexp-opt): * lisp/env.el (getenv): * lisp/simple.el (count-lines, mark, string-empty-p, lax-plist-get): * lisp/subr.el (ignore, always, zerop, fixnump, bignump, lsh, last) (eventp, mouse-movement-p, log10, memory-limit, string-greaterp) (interactive-p): * lisp/window.el (get-lru-window, get-largest-window, (window-edges) (window-body-edges, window-pixel-edges, window-body-pixel-edges) (window-absolute-pixel-edges, window-absolute-body-pixel-edges) (one-window-p): Declare functions `side-effect-free` and/or `pure` as appropriate.
* | Fix recent LAP optimiser errorMattias Engdegård2023-02-141-24/+32
| | | | | | | | | | | | | | | | | | | | * lisp/emacs-lisp/byte-opt.el (byte-optimize-lapcode): Fix a flaw in the dup (varset|varbind|stack-set) discard -> (varset|varbind|stack-set) rule: don't match stack-set(1) which is dealt with elsewhere, and generalise to discard(N).
* | LAP optimiser: more stack reduction hoistingMattias Engdegård2023-02-131-24/+43
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Hoisting stack reduction ops allows them to coalesce and/or cancel out pushing ops, and for useful operations to sink and combine, such as not + goto-if-[not-]nil. * lisp/emacs-lisp/byte-opt.el (byte-optimize-lapcode): Add the rule UNARY discardN-preserve-tos --> discardN-preserve-tos UNARY where UNARY pops and pushes one value. Generalise the rule const discardN-preserve-tos --> discardN const to any 0-ary op, not just const: varref, point, etc.
* | LAP peephole optimiser improvementsaMattias Engdegård2023-02-111-4/+97
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * lisp/emacs-lisp/byte-opt.el (byte-optimize-lapcode): Make the improvements: - Add the rule stack-ref(X) discardN-preserve-tos(Y) --> discard(Y) stack-ref(X-Y), X≥Y discard(X) discardN-preserve-tos(Y-X-1), X<Y with the usual equivalences: stack-set(1) = discardN-preserve-tos(1) stack-ref(0) = dup discard(0) = discardN-preserve-tos(0) = no-op This rule hoists stack reduction to where it is more likely to be exploited further, may reduce the op size through smaller immediates, and sometimes removes either or both operations outright. The rule is inhibited by an immediately following `return` op because other rules will produce better code in that case. - Add the rule (discardN-preserve-tos|dup) OP return --> OP return where OP is a unary operation such as `not` or `car`. - Generalise a previous rule to NOEFFECT PRODUCER return --> PRODUCER return where PRODUCER is now any op that pushes a value without looking at the stack: const, varref, point etc.
* | Flatten nested `concat` callsMattias Engdegård2023-02-081-12/+22
| | | | | | | | | | | | * lisp/emacs-lisp/byte-opt.el (byte-optimize-concat): Flatten nested forms; concat is associative. This reduces the number of calls and may coalesce adjacent constant strings.
* | Simplify and speed up parts of elisp optimiserMattias Engdegård2023-02-081-16/+25
| | | | | | | | | | | | | | | | * lisp/emacs-lisp/byte-opt.el (byte-optimize-constant-args): Simplify. (byte-optimize--constant-symbol-p): Speed up. (byteopt--eval-const): New. (byte-optimize-member, byte-optimize-concat, byte-optimize-append): Use byteopt--eval-const instead of eval which is much slower.
* | Fix misleading LAP optimiser debug log messageMattias Engdegård2023-02-051-2/+4
| | | | | | | | | | * lisp/emacs-lisp/byte-opt.el (byte-optimize-lapcode): Correct message in a conditional jump threading rule.
* | Allow unbind to commute with discardN and discardN-preserve-tosMattias Engdegård2023-02-051-1/+1
| | | | | | | | | | | | * lisp/emacs-lisp/byte-opt.el (byte-after-unbind-ops): Add discardN and discardN-preserve-tos, both of which commute with unbind. This enables subsequent optimisations.
* | Remove compatibility hacks in LAP optimiserMattias Engdegård2023-02-051-14/+4
| | | | | | | | | | | | | | * lisp/emacs-lisp/byte-opt.el (byte-optimize-lapcode): Remove code forcing forward motion after applying certain transformations; these were only there to keep output identical across refactorings.
* | LAP optimiser: bind local variables instead of mutating themMattias Engdegård2023-02-051-706/+745
| | | | | | | | | | | | | | | | | | | | | | | | | | This is a refactoring step: there is no change in how the optimiser works. * lisp/emacs-lisp/byte-opt.el (byte-optimize-lapcode): Instead of re-using local variables through mutation, bind them at point of use. This ensures that there is no value leakage by mistake and actually reduces the static size of the bytecode of this function somewhat. The lousy variable names (tmp, tmp2 etc) are retained but can at least now be changed into something more descriptive.
* | Get rid of delq in LAP optimiserMattias Engdegård2023-02-051-130/+159
| | | | | | | | | | | | | | * lisp/emacs-lisp/byte-opt.el (byte-optimize-lapcode): Instead of using the O(n) `delq' to remove single instructions, use the O(1) `setcdr'. To do this, anchor the instruction list in a cons cell and use the predecessor cell in iteration.
* | LAP peephole optimisation improvementsMattias Engdegård2023-02-021-38/+90
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | - Since discardN-preserve-tos(1) and stack-set(1) have the same effect, treat them as equivalent in all transformations. - Move the rule discardN-preserve-tos(X) discardN-preserve-tos(Y) --> discardN-preserve-tos(X+Y) from the final pass to the main iteration since it may enable further optimisations. - Don't apply the rule goto(X) ... X: DISCARD --> DISCARD goto(Y) ... X: DISCARD Y: when DISCARD could be merged or deleted instead, which is even better. - Add the rule OP const return -> <deleted> const return where OP is effect-free. - Generalise the push-pop annihilation rule to PUSH(K) discard(N) -> discard(N-K), N>K PUSH(K) discard(N) -> <deleted>, N=K to any N, not just N=1. - Add the rule OP goto(X) Y: OP X: -> <deleted> Y: OP X: for any operation OP. * lisp/emacs-lisp/byte-opt.el (byte-optimize-lapcode): Make the changes described above.
* | Clean up LAP peephole loggingMattias Engdegård2023-02-021-42/+41
| | | | | | | | | | | | | | | | | | | | | | | | | | Make `byte-compile-log-lap` more robust and produce nicer output. This is of interest for Elisp compiler maintainers only. * lisp/emacs-lisp/byte-opt.el (bytecomp--log-lap-arg): New. (byte-compile-log-lap-1): Extract argument conversion and rewrite in a more modern way, fixing bugs. In particular, tags are now displayed as "X:" where X is the tag number, and that tag number is shown as argument to goto-like ops. (byte-optimize-lapcode): Clean up and simplify logging, producing useful information when `byte-optimize-log` is `byte` as intended.
* | Better compilation of n-ary comparisonsMattias Engdegård2023-01-291-1/+43
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Transform n-ary comparisons to a chain of binary comparisons in the Lisp optimiser instead of in codegen, to allow for subsequent optimisations. This generalises the transform, so that (< 1 X 10) -> (let ((x X)) (and (< 1 x) (< x 10))) where (< 1 x) is then flipped to (> x 1) in codegen since it's slightly more efficient to have the constant argument last. Arguments that are neither constants nor variables are given temporary bindings. This results in about 2× speedup for 3-ary comparisons of fixnums with nontrivial arguments, and also improves the code slightly for binary comparisons with a constant first argument. * lisp/emacs-lisp/byte-opt.el (byte-opt--nary-comparison): New, set as the `byte-optimizer` property for =, <, <=, >, and >=. * lisp/emacs-lisp/bytecomp.el (byte-compile-and-folded): Rename to... (byte-compile-cmp): ...and rewrite.
* | Don't inhibit LAP-level DCE when switch ops are presentMattias Engdegård2023-01-271-8/+2
| | | | | | | | | | | | | | * lisp/emacs-lisp/byte-opt.el (byte-optimize-lapcode): Allow removal of unreachable basic blocks in the LAP peephole optimiser even when switch ops are present. The origins of this apparently unnecessary condition are unclear.
* | Optimise `apply` with `cons` in tail argumentMattias Engdegård2023-01-161-0/+3
| | | | | | | | | | | | | | | | | | * lisp/emacs-lisp/byte-opt.el (byte-optimize-apply): Transform (apply F ... (cons X Y)) -> (apply F ... X Y) This pattern is seen both in hand-written code and in backquote expansions.
* | Merge from origin/emacs-29Eli Zaretskii2023-01-011-1/+1
|\| | | | | | | | | | | | | | | | | | | | | cae528457c ; Add 2023 to copyright years. b394359261 Improve documentation of 'isearch-open-overlay-temporary' ab3210e709 Document 'use-package' in the 2 main manuals # Conflicts: # etc/refcards/ru-refcard.tex # lib/explicit_bzero.c # m4/explicit_bzero.m4
| * ; Add 2023 to copyright years.Eli Zaretskii2023-01-011-1/+1
| |
* | Fix condition-case body for-effect miscompilationMattias Engdegård2022-12-241-1/+4
| | | | | | | | | | | | | | | | | | | | | | (condition-case x A (:success B)) should not compile A for-effect even if the entire form is in for-effect context. * lisp/emacs-lisp/byte-opt.el (byte-optimize-form-code-walker): Don't optimise the condition-case body form for effect (potentially discarding its value) if there is a success handler and a variable. * test/lisp/emacs-lisp/bytecomp-tests.el (bytecomp-tests--test-cases): Add test cases.
* | Elide broken but unnecessary `if` optimisationsMattias Engdegård2022-12-191-5/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * lisp/emacs-lisp/byte-opt.el (byte-optimize-if): Remove explicit clauses purposing to simplify (if X nil t) -> (not X) (if X t nil) -> (not (not X)) but never did so because of a coding mistake (eq instead of equal), found by a recently added warning. They weren't actually needed thanks to the optimiser's fixpoint iteration: we eventually get the same results through (if X nil t) -> (if (not X) t nil) -> (if (not X) t) -> (not X) (if X t nil) -> (if X t) -> (not (not X))
* | Merge from origin/emacs-29Stefan Kangas2022-12-191-2/+5
|\| | | | | | | | | | | de2239a584a Revert "alist-get testfn argument evaluation correction" 856d889f3a8 Revert "Elide broken but unnecessary `if` optimisations" 8e42e20ed7f Revert "Use equal and member instead of eq and memq"
| * Revert "Elide broken but unnecessary `if` optimisations"Eli Zaretskii2022-12-161-2/+5
| | | | | | | | | | | | | | This reverts commit 13aa376e93564a8cf2ddbbcf0968c6666620db89. Please don't install anything on the release branch that is not a clear bugfix for a known bug.
| * Elide broken but unnecessary `if` optimisationsMattias Engdegård2022-12-161-5/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * lisp/emacs-lisp/byte-opt.el (byte-optimize-if): Remove explicit clauses purposing to simplify (if X nil t) -> (not X) (if X t nil) -> (not (not X)) but never did so because of a coding mistake (eq instead of equal), found by a recently added warning. They weren't actually needed thanks to the optimiser's fixpoint iteration: we eventually get the same results through (if X nil t) -> (if (not X) t nil) -> (if (not X) t) -> (not X) (if X t nil) -> (if X t) -> (not (not X))
* | Elide broken but unnecessary `if` optimisationsMattias Engdegård2022-12-161-5/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * lisp/emacs-lisp/byte-opt.el (byte-optimize-if): Remove explicit clauses purposing to simplify (if X nil t) -> (not X) (if X t nil) -> (not (not X)) but never did so because of a coding mistake (eq instead of equal), found by a recently added warning. They weren't actually needed thanks to the optimiser's fixpoint iteration: we eventually get the same results through (if X nil t) -> (if (not X) t nil) -> (if (not X) t) -> (not X) (if X t nil) -> (if X t) -> (not (not X))
* | Closures are always non-nilMattias Engdegård2022-12-161-1/+2
|/ | | | | * lisp/emacs-lisp/byte-opt.el (byte-compile-trueconstp): Treat closures as true in boolean context.
* ; Fix several symbol name typosStefan Kangas2022-10-261-1/+1
|
* ; Fix typos (prefer American spelling)Stefan Kangas2022-09-291-2/+2
|
* Boolean constant detection additionsMattias Engdegård2022-09-251-1/+2
| | | | | | * lisp/emacs-lisp/byte-opt.el (byte-opt--bool-value-form): `set` is boolean identity in its second argument. (byte-compile-trueconstp): `set-marker` is always true.
* Don't rewrite `set` to `setq` of lexical variablesMattias Engdegård2022-09-221-9/+10
| | | | | | | | | | | | | | | Only perform the rewrite (set 'VAR X) -> (setq VAR X) for dynamic variables, as `set` isn't supposed to affect lexical vars (and never does so when interpreted). * lisp/emacs-lisp/byte-opt.el (byte-optimize-set): * test/lisp/emacs-lisp/bytecomp-tests.el (bytecomp-tests--xx): New. (bytecomp-tests--test-cases): Add test cases. * test/lisp/emacs-lisp/bytecomp-resources/warn-variable-set-nonvariable.el: Remove obsolete test.
* Use `eql` or `eq` instead of `=` in some placesMattias Engdegård2022-09-151-4/+4
| | | | | | | | | | | | | | | | | For a switch op to be generated, comparisons must be made using `eq`, `eql` or `equal`, not `=`. * lisp/emacs-lisp/byte-opt.el (byte-optimize-lapcode): * lisp/files.el (file-modes-char-to-who, file-modes-char-to-right): * lisp/international/titdic-cnv.el (tit-process-header): * lisp/language/ethio-util.el (ethio-input-special-character) (ethio-fidel-to-tex-buffer): * lisp/language/lao.el (consonant): Use `eq` or `eql` instead of `=`. In these cases either `eq` or `eql` would do and the choice does not affect the resulting code. We compare numbers with `eql` and characters with `eq` as a matter of style.
* Update function properties and optimisationsMattias Engdegård2022-08-211-7/+13
| | | | | | | | | | * lisp/emacs-lisp/byte-opt.el (byte-opt--bool-value-form): Recognise boolean identity in aset, put, function-put and puthash. * lisp/emacs-lisp/byte-opt.el (byte-compile-trueconstp): Mark more functins as non-nil-returning, including the new pos-bol and pos-eol. * lisp/emacs-lisp/byte-opt.el (side-effect-free-fns): Mark pos-bol and pos-eol as side-effect-free.
* Move `while` syntax check from optimiser to macroexpandMattias Engdegård2022-08-191-3/+0
| | | | | * lisp/emacs-lisp/byte-opt.el (byte-optimize-while): Move check... * lisp/emacs-lisp/macroexp.el (macroexp--expand-all): ...here.
* More non-nil-returning functions in source optimisationMattias Engdegård2022-08-181-5/+24
| | | | | | | | | This change was partially generated and mechanically cross-validated with function type information from comp-known-type-specifiers in comp.el. * lisp/emacs-lisp/byte-opt.el (byte-compile-trueconstp): Extend list of functions and fix a typo (logxor).
* Improved `null` (alias `not`) optimisationMattias Engdegård2022-08-161-0/+11
| | | | | | Take static boolean information of the argument into account. * lisp/emacs-lisp/byte-opt.el (byte-optimize-not): New.
* Improved `and` and `or` optimisationMattias Engdegård2022-08-161-27/+84
| | | | | | * lisp/emacs-lisp/byte-opt.el (byte-optimize-and, byte-optimize-or): Rewrite. Avoid branching on arguments statically known to be true or false, and hoist code out to an unconditional prefix when possible.
* Improved `if` and `while` optimisationMattias Engdegård2022-08-161-38/+53
| | | | | | | | | | | | | Recognise some more special cases: (if X nil t) -> (not X) (if X t) -> (not (not X)) (if X t nil) -> (not (not X)) (if VAR VAR X...) -> (or VAR (progn X...)) * lisp/emacs-lisp/byte-opt.el (byte-opt-negate): New. (byte-optimize-if): Add transformations above and refactor. (byte-optimize-while): Better static nil-detection.
* Improved static detection of nil and non-nil expressionsMattias Engdegård2022-08-161-21/+69
| | | | | | | * lisp/emacs-lisp/byte-opt.el (byte-opt--bool-value-form): New. (byte-compile-trueconstp, byte-compile-nilconstp): Determine a static nil or non-nil result in more cases. These functions have grown and are no longer defsubst.
* (compiled-function-p): New function (bug#56648)Stefan Monnier2022-08-141-2/+1
| | | | | | | | | | | | | | | | | | | | | | | | * lisp/subr.el (compiled-function-p): New function. * test/lisp/international/ucs-normalize-tests.el (ucs-normalize-part1): * lisp/gnus/gnus.el (gnus): * lisp/mh-e/mh-e.el (mh-version): * lisp/emacs-lisp/macroexp.el (emacs-startup-hook): * lisp/emacs-lisp/cl-macs.el (compiled-function): * lisp/emacs-lisp/bytecomp.el (byte-compile-fdefinition) (byte-compile, display-call-tree): * lisp/emacs-lisp/byte-opt.el (<toplevel-end>): * lisp/emacs-lisp/advice.el (ad-compiled-p): * lisp/cedet/semantic/bovine.el (semantic-bovinate-stream): * lisp/loadup.el (macroexpand-all): * admin/unidata/unidata-gen.el (unidata--ensure-compiled): Use it. * lisp/emacs-lisp/pcase.el (pcase-mutually-exclusive-predicates): Add entries for it. (pcase--split-pred): Use it. * lisp/help-fns.el (help-fns-function-description-header): Use `functionp`. (help-fns--var-safe-local): Use `compiled-function-p`.
* Strength-reduce apply with (list ...) as tail argumentMattias Engdegård2022-08-141-18/+19
| | | | | * lisp/emacs-lisp/byte-opt.el (byte-optimize-apply): Transform (apply F ... (list X ...)) -> (funcall F ... X ...)
* Extend LAP optimisations to more operationsMattias Engdegård2022-08-101-7/+10
| | | | | | | | | | | | | | | | | Extend the set of eligible opcodes for certain peephole transformations, which then provide further optimisation opportunities. * lisp/emacs-lisp/byte-opt.el (byte-optimize-lapcode): Optimise empty save-current-buffer in the same way as we already do for save-excursion and save-restriction. This is safe because (save-current-buffer) is a no-op. (byte-compile-side-effect-and-error-free-ops): Add list3, list4 and listN. These were all apparent oversights as list1 and list2 were already included. (byte-after-unbind-ops): Add stack-ref, stack-set, discard, list3, list4 and listN. Stack manipulation is safe because unbind cannot read or modify stack entries.
* Delete redisplay-end-trigger-functions and related defunsStefan Kangas2022-07-311-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | This variable and related functions have been obsolete since 23.1. The last things to depend on this (fast-lock.el and lazy-lock.el) were recently removed. * src/dispextern.h (struct it): Delete field 'redisplay_end_trigger_charpos'. * src/window.c (Fwindow_redisplay_end_trigger) (Fset_window_redisplay_end_trigger): Delete defuns and corresponding defsubrs for functions obsolete since 23.1. * src/window.h (wset_redisplay_end_trigger): Delete function. (GCALIGNED_STRUCT): Delete 'redisplay_end_trigger'. * src/xdisp.c (run_redisplay_end_trigger_hook): Delete function. (syms_of_xdisp) <redisplay_end_trigger_functions>: Delete variable obsolete since 23.1. (init_iterator, next_element_from_buffer): Don't run or set above deleted hook variable. * lisp/subr.el: Delete obsoletion definitions for above deleted defuns and variable. * doc/lispref/hooks.texi (Standard Hooks): * lisp/emacs-lisp/byte-opt.el (side-effect-free-fns): * lisp/loadhist.el (unload-feature-special-hooks): Don't mention above deleted variable. * admin/coccinelle/window.cocci: Adjust for above changes.
* Cleanup `string-equal-ignore-case' declarations.Sam Steingold2022-07-281-4/+3
| | | | | | | | | | | | | | Also, a minor declaration cleanup for other `compare-strings' thin wrappers. * lisp/emacs-lisp/byte-opt.el (side-effect-free-fns): Remove `string-equal-ignore-case', `string-prefix-p', `string-suffix-p'. (side-effect-and-error-free-fns): Add `proper-list-p' (it already was in `pure-fns'). (pure-fns): Remove `string-prefix-p', `string-suffix-p' (`string-equal-ignore-case' was missing here). * lisp/subr.el (proper-list-p): Remove partially duplicate `put's from here. (string-equal-ignore-case, string-prefix-p, string-suffix-p): Add `pure' and `side-effect-free' declarations. (string-equal-ignore-case): Make inline.
* string-equal-ignore-case: new functionSam Steingold2022-07-261-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * lisp/cedet/semantic/complete.el (semantic-collector-calculate-completions): Use `string-prefix-p' instead of explicit `compare-strings'. * lisp/emacs-lisp/byte-opt.el (side-effect-free-fns): Add `string-equal-ignore-case'. * lisp/emacs-lisp/cl-extra.el (cl-equalp): Use `string-equal-ignore-case'. * lisp/emacs-lisp/shadow.el (load-path-shadows-find): Likewise. * lisp/emacs-lisp/shortdoc.el (string): Add `string-equal-ignore-case'. * lisp/files.el (file-truename): Use `string-equal-ignore-case'. (file-relative-name): Likewise. * lisp/gnus/gnus-art.el (article-hide-boring-headers): Use `string-equal-ignore-case' instead of `gnus-string-equal'. * lisp/gnus/gnus-util.el (gnus-string-equal): Remove, use `string-equal-ignore-case' instead. * lisp/international/mule-cmds.el (describe-language-environment): Use `string-equal-ignore-case'. (locale-charset-match-p): Likewise. * lisp/man.el (Man-softhyphen-to-minus): Use `string-prefix-p'. * lisp/minibuffer.el (completion--string-equal-p): Remove, use `string-equal-ignore-case' instead. (completion--twq-all): Use `string-equal-ignore-case'. (completion--do-completion): Likewise. * lisp/net/browse-url.el (browse-url-default-windows-browser): Use `string-prefix-p' instead of explicit `compare-strings'. * lisp/org/ob-core.el (org-babel-results-keyword): Use `string-equal-ignore-case' instead of explicit `compare-strings'. (org-babel-insert-result): Likewise. * lisp/org/org-compat.el (string-equal-ignore-case): Define unless defined already. (org-mode-flyspell-verify): Use `string-equal-ignore-case'. * lisp/org/org-lint.el (org-lint-duplicate-custom-id): Likewise. * lisp/org/ox.el (org-export-resolve-radio-link): Use `string-equal-ignore-case' and `string-clean-whitespace'. * lisp/progmodes/flymake-proc.el (flymake-proc--check-patch-master-file-buffer): Use `string-prefix-p' instead of explicit `compare-strings'. * lisp/progmodes/idlwave.el (idlwave-class-or-superclass-with-tag): Use `string-equal-ignore-case' instead of explicit `compare-strings'. * lisp/subr.el (member-ignore-case): Use `string-equal-ignore-case'. (string-equal-ignore-case): Compare strings ignoring case. * lisp/textmodes/bibtex.el (bibtex-string=): Remove. (bibtex-format-entry, bibtex-font-lock-url, bibtex-autofill-entry) (bibtex-print-help-message, bibtex-validate, bibtex-validate-globally) (bibtex-clean-entry, bibtex-completion-at-point-function, (bibtex-url): Use `string-equal-ignore-case' instead of `bibtex-string='. * lisp/textmodes/sgml-mode.el (sgml-get-context): Use `string-equal-ignore-case' instead of explicit `compare-strings'. (sgml-calculate-indent): Likewise * test/lisp/subr-tests.el (string-comparison-test): Add tests for `string-equal-ignore-case'.
* ; * lisp/emacs-lisp/byte-opt.el (byte-optimize--fixnump): Optimise.Mattias Engdegård2022-07-211-1/+1
|
* Add `take` and `ntake` (bug#56521)Mattias Engdegård2022-07-171-2/+2
| | | | | | | | | | | | | | These are useful list primitives, complementary to `nthcdr`. * src/fns.c (Ftake, Fntake): New. (syms_of_fns): Defsubr them. * doc/lispref/lists.texi (List Elements): * lisp/emacs-lisp/shortdoc.el (list): Document. * lisp/emacs-lisp/byte-opt.el (side-effect-free-fns, pure-fns): Declare `take` pure and side-effect-free. * test/src/fns-tests.el (fns-tests--take-ref, fns--take-ntake): New test. * etc/NEWS: Announce.
* Optimise `append` callsMattias Engdegård2022-07-161-0/+78
| | | | | | | | | | | | | | | | | | | | | Add the transforms (append) -> nil (append X) -> X (append '(X) Y) -> (cons 'X Y) (append (list X) Y) -> (cons X Y) (append (list X...) nil) -> (list X...) and the argument transforms: (list X...) (list Y...) -> (list X... Y...) nil -> ;nothing CONST1 CONST2 -> CONST1++CONST2 (list CONSTANTS...) -> '(CONSTANTS...) (the last three for non-tail arguments only) * lisp/emacs-lisp/byte-opt.el: New.
* Improved cons optimisationMattias Engdegård2022-07-161-5/+8
| | | | | | | * lisp/emacs-lisp/byte-opt.el (byte-optimize-cons): Add the transform (cons X (list Y...)) -> (list X Y...)
* Transform (list) -> nil in source optimiserMattias Engdegård2022-07-161-0/+5
| | | | | | | | This optimisation is already done in the code generator but performing it at this earlier stage is a useful normalising step that uncovers more opportunities. * lisp/emacs-lisp/byte-opt.el (byte-optimize-list): New.
* ; Fix typos: prefer American spellingStefan Kangas2022-07-141-1/+1
|
* Merge from origin/emacs-28Stefan Kangas2022-07-141-16/+16
|\ | | | | | | | | | | | | | | | | | | | | | | 5e47ec9511 ; * lisp/url/url-http.el (url-http-parse-headers): Fix typo. ba0871bef1 ; Fix typos: prefer American spelling e3e7f31faa Adapt Tramp doc # Conflicts: # etc/NEWS # etc/themes/modus-themes.el # lisp/emacs-lisp/byte-opt.el # test/lisp/so-long-tests/spelling-tests.el