summaryrefslogtreecommitdiff
path: root/lisp/emacs-lisp/byte-opt.el
diff options
context:
space:
mode:
Diffstat (limited to 'lisp/emacs-lisp/byte-opt.el')
-rw-r--r--lisp/emacs-lisp/byte-opt.el386
1 files changed, 254 insertions, 132 deletions
diff --git a/lisp/emacs-lisp/byte-opt.el b/lisp/emacs-lisp/byte-opt.el
index 3c7aeb89525..2bdd3375728 100644
--- a/lisp/emacs-lisp/byte-opt.el
+++ b/lisp/emacs-lisp/byte-opt.el
@@ -506,13 +506,7 @@ for speeding up processing.")
((guard (when for-effect
(if-let ((tmp (byte-opt--fget fn 'side-effect-free)))
(or byte-compile-delete-errors
- (eq tmp 'error-free)
- (progn
- (byte-compile-warn-x
- form
- "value returned from %s is unused"
- form)
- nil)))))
+ (eq tmp 'error-free)))))
(byte-compile-log " %s called for effect; deleted" fn)
(byte-optimize-form (cons 'progn (cdr form)) t))
@@ -1642,98 +1636,231 @@ See Info node `(elisp) Integer Basics'."
;; I wonder if I missed any :-\)
(let ((side-effect-free-fns
- '(% * + - / /= 1+ 1- < <= = > >= abs acos append aref ash asin atan
- assq
- base64-decode-string base64-encode-string base64url-encode-string
+ '(
+ ;; alloc.c
+ make-bool-vector make-byte-code make-list make-record make-string
+ make-symbol make-vector
+ ;; buffer.c
+ buffer-base-buffer buffer-chars-modified-tick buffer-file-name
+ buffer-local-value buffer-local-variables buffer-modified-p
+ buffer-modified-tick buffer-name get-buffer next-overlay-change
+ overlay-buffer overlay-end overlay-get overlay-properties
+ overlay-start overlays-at overlays-in previous-overlay-change
+ ;; callint.c
+ prefix-numeric-value
+ ;; casefiddle.c
+ capitalize downcase upcase upcase-initials
+ ;; category.c
+ category-docstring category-set-mnemonics char-category-set
+ copy-category-table get-unused-category make-category-set
+ ;; character.c
+ char-width multibyte-char-to-unibyte string unibyte-char-to-multibyte
+ ;; charset.c
+ decode-char encode-char
+ ;; chartab.c
+ make-char-table
+ ;; data.c
+ % * + - / /= 1+ 1- < <= = > >=
+ aref ash bare-symbol
bool-vector-count-consecutive bool-vector-count-population
bool-vector-subsetp
- boundp buffer-file-name buffer-local-variables buffer-modified-p
- buffer-substring byte-code-function-p
- capitalize car-less-than-car car cdr ceiling char-after char-before
- char-equal char-to-string char-width compare-strings
- window-configuration-equal-p concat coordinates-in-window-p
- copy-alist copy-sequence copy-marker copysign cos
- current-time-string current-time-zone
- decode-char
- decode-time default-boundp default-value documentation downcase
- elt encode-char exp expt encode-time error-message-string
- fboundp fceiling featurep ffloor
- file-directory-p file-exists-p file-locked-p file-name-absolute-p
- file-name-concat
- file-newer-than-file-p file-readable-p file-symlink-p file-writable-p
- float float-time floor format format-message format-time-string
- frame-first-window frame-root-window frame-selected-window
- frame-visible-p fround ftruncate
- get gethash get-buffer get-buffer-window get-file-buffer
- hash-table-count
- intern-soft isnan
- keymap-parent
- ldexp
- length length< length> length=
- line-beginning-position line-end-position pos-bol pos-eol
- local-variable-if-set-p local-variable-p locale-info
- log logand logb logcount logior lognot logxor
- make-byte-code make-list make-string make-symbol marker-buffer max
- match-beginning match-end
- member memq memql min minibuffer-selected-window minibuffer-window
- mod multibyte-char-to-unibyte next-window nth nthcdr number-to-string
- prefix-numeric-value previous-window prin1-to-string propertize
- rassq rassoc read-from-string
- regexp-quote region-beginning region-end reverse round
- sin sqrt string string-equal string-lessp
- string-search string-to-char
- string-to-number string-to-syntax substring substring-no-properties
- sxhash-equal sxhash-eq sxhash-eql
- symbol-function symbol-name symbol-plist symbol-value
- string-make-unibyte
- string-make-multibyte string-as-multibyte string-as-unibyte
- string-to-multibyte
- take tan time-convert truncate
- unibyte-char-to-multibyte upcase user-full-name
- user-login-name
- vconcat
- window-at window-body-height
- window-body-width window-buffer window-dedicated-p window-display-table
- window-combination-limit window-frame window-fringes
- window-hscroll
- window-left-child window-left-column window-margins window-minibuffer-p
- window-next-buffers window-next-sibling window-new-normal
- window-new-total window-normal-size window-parameter window-parameters
- window-parent window-point window-prev-buffers
- window-prev-sibling window-scroll-bars
- window-start window-text-height window-top-child window-top-line
- window-total-height window-total-width window-use-time window-vscroll
- ))
+ boundp car cdr default-boundp default-value fboundp
+ get-variable-watchers indirect-variable
+ local-variable-if-set-p local-variable-p
+ logand logcount logior lognot logxor max min mod
+ number-to-string position-symbol string-to-number
+ subr-arity subr-name subr-native-lambda-list subr-type
+ symbol-function symbol-name symbol-plist symbol-value
+ symbol-with-pos-pos variable-binding-locus
+ ;; doc.c
+ documentation
+ ;; editfns.c
+ buffer-substring buffer-substring-no-properties
+ byte-to-position byte-to-string
+ char-after char-before char-equal char-to-string
+ compare-buffer-substrings
+ format format-message
+ group-name
+ line-beginning-position line-end-position ngettext pos-bol pos-eol
+ propertize region-beginning region-end string-to-char
+ user-full-name user-login-name
+ ;; fileio.c
+ car-less-than-car directory-name-p file-directory-p file-exists-p
+ file-name-absolute-p file-name-concat file-newer-than-file-p
+ file-readable-p file-symlink-p file-writable-p
+ ;; filelock.c
+ file-locked-p
+ ;; floatfns.c
+ abs acos asin atan ceiling copysign cos exp expt fceiling ffloor
+ float floor fround ftruncate isnan ldexp log logb round sin sqrt tan
+ truncate
+ ;; fns.c
+ append assq
+ base64-decode-string base64-encode-string base64url-encode-string
+ compare-strings concat copy-alist copy-hash-table copy-sequence elt
+ featurep get
+ gethash hash-table-count hash-table-rehash-size
+ hash-table-rehash-threshold hash-table-size hash-table-test
+ hash-table-weakness
+ length length< length= length>
+ line-number-at-pos locale-info make-hash-table
+ member memq memql nth nthcdr
+ object-intervals rassoc rassq reverse
+ string-as-multibyte string-as-unibyte string-bytes string-distance
+ string-equal string-lessp string-make-multibyte string-make-unibyte
+ string-search string-to-multibyte substring substring-no-properties
+ sxhash-eq sxhash-eql sxhash-equal sxhash-equal-including-properties
+ take vconcat
+ ;; frame.c
+ frame-ancestor-p frame-bottom-divider-width frame-char-height
+ frame-char-width frame-child-frame-border-width frame-focus
+ frame-fringe-width frame-internal-border-width frame-native-height
+ frame-native-width frame-parameter frame-parameters frame-parent
+ frame-pointer-visible-p frame-position frame-right-divider-width
+ frame-scale-factor frame-scroll-bar-height frame-scroll-bar-width
+ frame-text-cols frame-text-height frame-text-lines frame-text-width
+ frame-total-cols frame-total-lines frame-visible-p
+ frame-window-state-change next-frame previous-frame
+ tool-bar-pixel-width window-system
+ ;; fringe.c
+ fringe-bitmaps-at-pos
+ ;; keyboard.c
+ posn-at-point posn-at-x-y
+ ;; keymap.c
+ copy-keymap keymap-parent keymap-prompt make-keymap make-sparse-keymap
+ ;; lread.c
+ intern-soft read-from-string
+ ;; marker.c
+ copy-marker marker-buffer marker-insertion-type marker-position
+ ;; minibuf.c
+ active-minibuffer-window assoc-string innermost-minibuffer-p
+ minibuffer-innermost-command-loop-p minibufferp
+ ;; print.c
+ error-message-string prin1-to-string
+ ;; process.c
+ format-network-address get-buffer-process get-process
+ process-buffer process-coding-system process-command process-filter
+ process-id process-inherit-coding-system-flag process-mark
+ process-name process-plist process-query-on-exit-flag
+ process-running-child-p process-sentinel process-thread
+ process-tty-name process-type
+ ;; search.c
+ match-beginning match-end regexp-quote
+ ;; sqlite.c
+ sqlite-columns sqlite-more-p sqlite-version
+ ;; syntax.c
+ char-syntax copy-syntax-table matching-paren string-to-syntax
+ syntax-class-to-char
+ ;; term.c
+ controlling-tty-p tty-display-color-cells tty-display-color-p
+ tty-top-frame tty-type
+ ;; terminal.c
+ frame-terminal terminal-list terminal-live-p terminal-name
+ terminal-parameter terminal-parameters
+ ;; textprop.c
+ get-char-property get-char-property-and-overlay get-text-property
+ next-char-property-change next-property-change
+ next-single-char-property-change next-single-property-change
+ previous-char-property-change previous-property-change
+ previous-single-char-property-change previous-single-property-change
+ text-properties-at text-property-any text-property-not-all
+ ;; thread.c
+ all-threads condition-mutex condition-name mutex-name thread-live-p
+ thread-name
+ ;; timefns.c
+ current-time-string current-time-zone decode-time encode-time
+ float-time format-time-string time-add time-convert time-equal-p
+ time-less-p time-subtract
+ ;; window.c
+ coordinates-in-window-p frame-first-window frame-root-window
+ frame-selected-window get-buffer-window minibuffer-selected-window
+ minibuffer-window next-window previous-window window-at
+ window-body-height window-body-width window-buffer
+ window-combination-limit window-configuration-equal-p
+ window-dedicated-p window-display-table window-frame window-fringes
+ window-hscroll window-left-child window-left-column window-margins
+ window-minibuffer-p window-new-normal window-new-total
+ window-next-buffers window-next-sibling window-normal-size
+ window-parameter window-parameters window-parent window-point
+ window-prev-buffers window-prev-sibling window-scroll-bars
+ window-start window-text-height window-top-child window-top-line
+ window-total-height window-total-width window-use-time window-vscroll
+ ;; xdisp.c
+ buffer-text-pixel-size current-bidi-paragraph-direction
+ get-display-property invisible-p line-pixel-height lookup-image-map
+ tab-bar-height tool-bar-height window-text-pixel-size
+ ))
(side-effect-and-error-free-fns
- '(arrayp atom
- bobp bolp bool-vector-p
- buffer-list buffer-size buffer-string bufferp
- car-safe case-table-p cdr-safe char-or-string-p characterp
- charsetp commandp cons consp
- current-buffer current-global-map current-indentation
- current-local-map current-minor-mode-maps current-time
- eobp eolp eq equal
- floatp following-char framep
- hash-table-p
- identity indirect-function integerp integer-or-marker-p
- invocation-directory invocation-name
- keymapp keywordp
- list listp
- make-marker mark-marker markerp max-char
- natnump nlistp null number-or-marker-p numberp
- overlayp
- point point-marker point-min point-max preceding-char
- processp proper-list-p
- recent-keys recursion-depth
- safe-length selected-frame selected-window sequencep
- standard-case-table standard-syntax-table stringp subrp symbolp
- syntax-table syntax-table-p
- this-command-keys this-command-keys-vector this-single-command-keys
- this-single-command-raw-keys type-of
- user-real-login-name user-real-uid user-uid
- vector vectorp visible-frame-list
- wholenump window-configuration-p window-live-p
- window-valid-p windowp)))
+ '(
+ ;; alloc.c
+ bool-vector cons list make-marker purecopy record vector
+ ;; buffer.c
+ buffer-list buffer-live-p current-buffer overlay-lists overlayp
+ ;; casetab.c
+ case-table-p current-case-table standard-case-table
+ ;; category.c
+ category-table category-table-p make-category-table
+ standard-category-table
+ ;; character.c
+ characterp max-char
+ ;; charset.c
+ charsetp
+ ;; data.c
+ arrayp atom bare-symbol-p bool-vector-p bufferp byte-code-function-p
+ byteorder car-safe cdr-safe char-or-string-p char-table-p
+ condition-variable-p consp eq floatp indirect-function
+ integer-or-marker-p integerp keywordp listp markerp
+ module-function-p multibyte-string-p mutexp natnump nlistp null
+ number-or-marker-p numberp recordp remove-pos-from-symbol
+ sequencep stringp subr-native-elisp-p subrp symbol-with-pos-p symbolp
+ threadp type-of user-ptrp vector-or-char-table-p vectorp wholenump
+ ;; editfns.c
+ bobp bolp buffer-size buffer-string current-message emacs-pid
+ eobp eolp following-char gap-position gap-size group-gid
+ group-real-gid mark-marker point point-marker point-max point-min
+ position-bytes preceding-char system-name
+ user-real-login-name user-real-uid user-uid
+ ;; emacs.c
+ invocation-directory invocation-name
+ ;; eval.c
+ commandp functionp
+ ;; fileio.c
+ default-file-modes
+ ;; fns.c
+ eql equal hash-table-p identity proper-list-p safe-length
+ secure-hash-algorithms
+ ;; frame.c
+ frame-list frame-live-p framep last-nonminibuffer-frame
+ old-selected-frame selected-frame visible-frame-list
+ ;; image.c
+ imagep
+ ;; indent.c
+ current-column current-indentation
+ ;; keyboard.c
+ current-idle-time current-input-mode recent-keys recursion-depth
+ this-command-keys this-command-keys-vector this-single-command-keys
+ this-single-command-raw-keys
+ ;; keymap.c
+ current-global-map current-local-map current-minor-mode-maps keymapp
+ ;; minibuf.c
+ minibuffer-contents minibuffer-contents-no-properties minibuffer-depth
+ minibuffer-prompt minibuffer-prompt-end
+ ;; process.c
+ process-list processp signal-names waiting-for-user-input-p
+ ;; sqlite.c
+ sqlite-available-p sqlitep
+ ;; syntax.c
+ standard-syntax-table syntax-table syntax-table-p
+ ;; thread.c
+ current-thread
+ ;; timefns.c
+ current-time
+ ;; window.c
+ selected-window window-configuration-p window-live-p window-valid-p
+ windowp
+ ;; xdisp.c
+ long-line-optimizations-p
+ )))
(while side-effect-free-fns
(put (car side-effect-free-fns) 'side-effect-free t)
(setq side-effect-free-fns (cdr side-effect-free-fns)))
@@ -1758,41 +1885,34 @@ See Info node `(elisp) Integer Basics'."
;; values if a marker is moved.
(let ((pure-fns
- '(concat regexp-quote
- string-to-char string-to-syntax symbol-name
- eq eql
- = /= < <= >= > min max
- + - * / % mod abs ash 1+ 1- sqrt
- logand logior lognot logxor logcount
- copysign isnan ldexp float logb
- floor ceiling round truncate
- ffloor fceiling fround ftruncate
- string-equal string-lessp
- string-search
- consp atom listp nlistp proper-list-p
- sequencep arrayp vectorp stringp bool-vector-p hash-table-p
- null
- numberp integerp floatp natnump characterp
- integer-or-marker-p number-or-marker-p char-or-string-p
- symbolp keywordp
- type-of
- identity
-
- ;; The following functions are pure up to mutation of their
- ;; arguments. This is pure enough for the purposes of
- ;; constant folding, but not necessarily for all kinds of
- ;; code motion.
- car cdr car-safe cdr-safe nth nthcdr take
- equal
- length safe-length
- memq memql member
- ;; `assoc' and `assoc-default' are excluded since they are
- ;; impure if the test function is (consider `string-match').
- assq rassq rassoc
- aref elt
- base64-decode-string base64-encode-string base64url-encode-string
- bool-vector-subsetp
- bool-vector-count-population bool-vector-count-consecutive
+ '(
+ ;; character.c
+ characterp
+ ;; data.c
+ % * + - / /= 1+ 1- < <= = > >= aref arrayp ash atom bare-symbol
+ bool-vector-count-consecutive bool-vector-count-population
+ bool-vector-p bool-vector-subsetp
+ bufferp car car-safe cdr cdr-safe char-or-string-p char-table-p
+ condition-variable-p consp eq floatp integer-or-marker-p integerp
+ keywordp listp logand logcount logior lognot logxor markerp max min
+ mod multibyte-string-p mutexp natnump nlistp null number-or-marker-p
+ numberp recordp remove-pos-from-symbol sequencep stringp symbol-name
+ symbolp threadp type-of vector-or-char-table-p vectorp
+ ;; editfns.c
+ string-to-char
+ ;; floatfns.c
+ abs ceiling copysign fceiling ffloor float floor fround ftruncate
+ isnan ldexp logb round sqrt truncate
+ ;; fns.c
+ assq base64-decode-string base64-encode-string base64url-encode-string
+ concat elt eql equal hash-table-p identity length length< length=
+ length> member memq memql nth nthcdr proper-list-p rassoc rassq
+ safe-length string-bytes string-distance string-equal string-lessp
+ string-search take
+ ;; search.c
+ regexp-quote
+ ;; syntax.c
+ string-to-syntax
)))
(while pure-fns
(put (car pure-fns) 'pure t)
@@ -2765,7 +2885,9 @@ If FOR-EFFECT is non-nil, the return value is assumed to be of no importance."
(or (memq (caar tmp) '(byte-discard byte-discardN))
;; Make sure we don't hoist a discardN-preserve-tos
;; that really should be merged or deleted instead.
- (and (eq (caar tmp) 'byte-discardN-preserve-tos)
+ (and (or (eq (caar tmp) 'byte-discardN-preserve-tos)
+ (and (eq (caar tmp) 'byte-stack-set)
+ (eql (cdar tmp) 1)))
(let ((next (cadr tmp)))
(not (or (memq (car next)
'(byte-discardN-preserve-tos