diff options
| author | Mattias EngdegÄrd | 2022-03-16 16:24:24 +0100 |
|---|---|---|
| committer | Mattias EngdegÄrd | 2022-04-04 09:49:31 +0200 |
| commit | f4833c88bbb3ca69f75e230a50bbd5edb4d5c00d (patch) | |
| tree | d36d89e233f8a0a9510bb00669cd95dd7fedfdae | |
| parent | 16ee9fa138817c061d00cf9a59d2b3f559eebfe1 (diff) | |
| download | emacs-f4833c88bbb3ca69f75e230a50bbd5edb4d5c00d.tar.gz emacs-f4833c88bbb3ca69f75e230a50bbd5edb4d5c00d.zip | |
Rewrite string-greaterp and string> using string-lessp
Since string-lessp has its own byte-op, using it is much faster than
calling string-greaterp even with the need to bind a temporary
variable.
* lisp/emacs-lisp/byte-opt.el (byte-optimize-string-greaterp): New.
(string-greaterp, string>): Set byte-optimizer.
| -rw-r--r-- | lisp/emacs-lisp/byte-opt.el | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/lisp/emacs-lisp/byte-opt.el b/lisp/emacs-lisp/byte-opt.el index 0a79bf9b797..39bb6224595 100644 --- a/lisp/emacs-lisp/byte-opt.el +++ b/lisp/emacs-lisp/byte-opt.el | |||
| @@ -1049,6 +1049,14 @@ See Info node `(elisp) Integer Basics'." | |||
| 1049 | form ; No improvement. | 1049 | form ; No improvement. |
| 1050 | (cons 'concat (nreverse newargs))))) | 1050 | (cons 'concat (nreverse newargs))))) |
| 1051 | 1051 | ||
| 1052 | (defun byte-optimize-string-greaterp (form) | ||
| 1053 | ;; Rewrite in terms of `string-lessp' which has its own bytecode. | ||
| 1054 | (pcase (cdr form) | ||
| 1055 | (`(,a ,b) (let ((arg1 (make-symbol "arg1"))) | ||
| 1056 | `(let ((,arg1 ,a)) | ||
| 1057 | (string-lessp ,b ,arg1)))) | ||
| 1058 | (_ form))) | ||
| 1059 | |||
| 1052 | (put 'identity 'byte-optimizer #'byte-optimize-identity) | 1060 | (put 'identity 'byte-optimizer #'byte-optimize-identity) |
| 1053 | (put 'memq 'byte-optimizer #'byte-optimize-memq) | 1061 | (put 'memq 'byte-optimizer #'byte-optimize-memq) |
| 1054 | (put 'memql 'byte-optimizer #'byte-optimize-member) | 1062 | (put 'memql 'byte-optimizer #'byte-optimize-member) |
| @@ -1072,6 +1080,9 @@ See Info node `(elisp) Integer Basics'." | |||
| 1072 | (put 'string= 'byte-optimizer #'byte-optimize-binary-predicate) | 1080 | (put 'string= 'byte-optimizer #'byte-optimize-binary-predicate) |
| 1073 | (put 'string-equal 'byte-optimizer #'byte-optimize-binary-predicate) | 1081 | (put 'string-equal 'byte-optimizer #'byte-optimize-binary-predicate) |
| 1074 | 1082 | ||
| 1083 | (put 'string-greaterp 'byte-optimizer #'byte-optimize-string-greaterp) | ||
| 1084 | (put 'string> 'byte-optimizer #'byte-optimize-string-greaterp) | ||
| 1085 | |||
| 1075 | (put 'concat 'byte-optimizer #'byte-optimize-concat) | 1086 | (put 'concat 'byte-optimizer #'byte-optimize-concat) |
| 1076 | 1087 | ||
| 1077 | ;; I'm not convinced that this is necessary. Doesn't the optimizer loop | 1088 | ;; I'm not convinced that this is necessary. Doesn't the optimizer loop |