[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/relint 62ca3d4 05/44: Slight performance improvement
From: |
Mattias Engdegård |
Subject: |
[elpa] externals/relint 62ca3d4 05/44: Slight performance improvement |
Date: |
Tue, 26 Mar 2019 12:57:24 -0400 (EDT) |
branch: externals/relint
commit 62ca3d4dc94986de1cb948fc28582ea22a415ad0
Author: Mattias Engdegård <address@hidden>
Commit: Mattias Engdegård <address@hidden>
Slight performance improvement
Remove a function call in the inner loop in the common case.
---
trawl.el | 158 ++++++++++++++++++++++++++++++---------------------------------
1 file changed, 74 insertions(+), 84 deletions(-)
diff --git a/trawl.el b/trawl.el
index ab4295b..48ef364 100644
--- a/trawl.el
+++ b/trawl.el
@@ -245,92 +245,82 @@
(trawl--peel-list form)))
(defun trawl--check-form-recursively (form file pos path)
- (when (consp form)
- (pcase form
-; (`(apply ,(or `nconc `(quote nconc) `(function nconc)) (mapcar . ,_))
-; (trawl--report file pos path
-; "use mapcan instead of (apply nconc (mapcar...))"))
-; (`(lambda (,var1) (,_ ,var2))
-; (when (eq var1 var2)
-; (trawl--report file pos path
-; "lambda expression can be η-reduced")))
-; (`(lambda (,var1) ,var2)
-; (when (eq var1 var2)
-; (trawl--report file pos path
-; "lambda expression is #'identity")))
-; (`(defun ,name ,_ . ,body)
-; (let ((f body))
-; (while (and f (consp (car f)) (eq (caar f) 'declare))
-; (setq f (cdr f)))
-; (when (and f (consp (car f)))
-; (setq f (cdr f))
-; (while (cdr f)
-; (when (stringp (car f))
-; (trawl--report file pos path
-; (format "defun %s: misplaced doc string" name)))
-; (setq f (cdr f))))))
- (`(,(or `looking-at `re-search-forward `re-search-backward
- `string-match `string-match-p `looking-back `looking-at-p
- `replace-regexp-in-string 'replace-regexp
- `query-replace-regexp
- `posix-looking-at `posix-search-backward `posix-search-forward
- `posix-string-match)
- ,re-arg . ,_)
- (unless (and (symbolp re-arg)
- (memq re-arg trawl--checked-variables))
- (trawl--check-re re-arg (format "call to %s" (car form))
- file pos (cons 1 path))))
- (`(,(or `defvar `defconst 'defcustom)
- ,name ,re-arg . ,rest)
- (when (symbolp name)
- (cond
- ((string-match-p (rx (or "-regexp" "-re" "-regex" "-pattern") eos)
- (symbol-name name))
- (trawl--check-re re-arg name file pos (cons 2 path))
- (push name trawl--checked-variables))
- ((string-match-p (rx (or "-regexps" "-regexes" "-patterns") eos)
- (symbol-name name))
- (trawl--check-list re-arg name file pos (cons 2 path))
- (push name trawl--checked-variables))
- ((string-match-p (rx "-font-lock-keywords" eos)
- (symbol-name name))
- (trawl--check-font-lock-keywords re-arg name file pos (cons 2 path))
- (push name trawl--checked-variables))
- ((eq name 'compilation-error-regexp-alist-alist)
- (trawl--check-compilation-error-regexp-alist-alist
- re-arg name file pos (cons 2 path))
- (push name trawl--checked-variables))
- ((string-match-p (rx (or "-regexp" "-re" "-regex" "-pattern")
- "-alist" eos)
- (symbol-name name))
- (trawl--check-list-car re-arg name file pos (cons 2 path))
- (push name trawl--checked-variables))
- ((string-match-p (rx "-rules-list" eos)
- (symbol-name name))
- (trawl--check-rules-list re-arg name file pos (cons 2 path))
- (push name trawl--checked-variables))
- ;; Doc string starting with "regexp"?
- ((and (stringp (car rest))
- (let ((case-fold-search t))
- (string-match-p (rx bos "regexp") (car rest))))
- (trawl--check-re re-arg name file pos (cons 2 path))
- (push name trawl--checked-variables))
- )
- (push (cons name re-arg) trawl--variables)))
- (`(define-generic-mode ,name ,_ ,_ ,font-lock-list ,auto-mode-list . ,_)
- (let ((origin (format "define-generic-mode %s" name)))
- (trawl--check-font-lock-keywords font-lock-list origin
- file pos (cons 4 path))
- (trawl--check-list auto-mode-list origin file pos (cons 5 path))))
- )
- (let ((index 0))
- (while (consp form)
- (trawl--check-form-recursively (car form) file pos (cons index path))
- (setq form (cdr form))
- (setq index (1+ index))))))
+ (pcase form
+;;; (`(defun ,name ,_ . ,body)
+;;; (let ((f body))
+;;; (while (and f (consp (car f)) (eq (caar f) 'declare))
+;;; (setq f (cdr f)))
+;;; (when (and f (consp (car f)))
+;;; (setq f (cdr f))
+;;; (while (cdr f)
+;;; (when (stringp (car f))
+;;; (trawl--report file pos path
+;;; (format "defun %s: misplaced doc string" name)))
+;;; (setq f (cdr f))))))
+ (`(,(or `looking-at `re-search-forward `re-search-backward
+ `string-match `string-match-p `looking-back `looking-at-p
+ `replace-regexp-in-string `replace-regexp
+ `query-replace-regexp
+ `posix-looking-at `posix-search-backward `posix-search-forward
+ `posix-string-match)
+ ,re-arg . ,_)
+ (unless (and (symbolp re-arg)
+ (memq re-arg trawl--checked-variables))
+ (trawl--check-re re-arg (format "call to %s" (car form))
+ file pos (cons 1 path))))
+ (`(,(or `defvar `defconst `defcustom)
+ ,name ,re-arg . ,rest)
+ (when (symbolp name)
+ (cond
+ ((string-match-p (rx (or "-regexp" "-re" "-regex" "-pattern") eos)
+ (symbol-name name))
+ (trawl--check-re re-arg name file pos (cons 2 path))
+ (push name trawl--checked-variables))
+ ((string-match-p (rx (or "-regexps" "-regexes" "-patterns") eos)
+ (symbol-name name))
+ (trawl--check-list re-arg name file pos (cons 2 path))
+ (push name trawl--checked-variables))
+ ((string-match-p (rx "-font-lock-keywords" eos)
+ (symbol-name name))
+ (trawl--check-font-lock-keywords re-arg name file pos (cons 2 path))
+ (push name trawl--checked-variables))
+ ((eq name 'compilation-error-regexp-alist-alist)
+ (trawl--check-compilation-error-regexp-alist-alist
+ re-arg name file pos (cons 2 path))
+ (push name trawl--checked-variables))
+ ((string-match-p (rx (or "-regexp" "-re" "-regex" "-pattern")
+ "-alist" eos)
+ (symbol-name name))
+ (trawl--check-list-car re-arg name file pos (cons 2 path))
+ (push name trawl--checked-variables))
+ ((string-match-p (rx "-rules-list" eos)
+ (symbol-name name))
+ (trawl--check-rules-list re-arg name file pos (cons 2 path))
+ (push name trawl--checked-variables))
+ ;; Doc string starting with "regexp"?
+ ((and (stringp (car rest))
+ (let ((case-fold-search t))
+ (string-match-p (rx bos "regexp") (car rest))))
+ (trawl--check-re re-arg name file pos (cons 2 path))
+ (push name trawl--checked-variables))
+ )
+ (push (cons name re-arg) trawl--variables)))
+ (`(define-generic-mode ,name ,_ ,_ ,font-lock-list ,auto-mode-list . ,_)
+ (let ((origin (format "define-generic-mode %s" name)))
+ (trawl--check-font-lock-keywords font-lock-list origin
+ file pos (cons 4 path))
+ (trawl--check-list auto-mode-list origin file pos (cons 5 path))))
+ )
+ (let ((index 0))
+ (while (consp form)
+ (when (consp (car form))
+ (trawl--check-form-recursively (car form) file pos (cons index path)))
+ (setq form (cdr form))
+ (setq index (1+ index)))))
(defun trawl--check-toplevel-form (form file pos)
- (trawl--check-form-recursively form file pos nil))
+ (when (consp form)
+ (trawl--check-form-recursively form file pos nil)))
(defun trawl--show-errors ()
(unless noninteractive
- [elpa] externals/relint 683f31b 28/44: Increment version to 1.3, (continued)
- [elpa] externals/relint 683f31b 28/44: Increment version to 1.3, Mattias Engdegård, 2019/03/26
- [elpa] externals/relint ac5d0cf 25/44: Add more safe functions, Mattias Engdegård, 2019/03/26
- [elpa] externals/relint 02bf0ba 21/44: Use explicit list of pure functions, Mattias Engdegård, 2019/03/26
- [elpa] externals/relint 7d0e177 20/44: Rewrite the higher-order function handling, Mattias Engdegård, 2019/03/26
- [elpa] externals/relint be3979a 19/44: Check TRIM argument of `split-string' as well, Mattias Engdegård, 2019/03/26
- [elpa] externals/relint 5143edf 17/44: Fix indentation accidents, Mattias Engdegård, 2019/03/26
- [elpa] externals/relint d6320f9 14/44: Detect functions with regexp arguments, Mattias Engdegård, 2019/03/26
- [elpa] externals/relint d19133e 09/44: Better variable name patterns, Mattias Engdegård, 2019/03/26
- [elpa] externals/relint d4d8f97 11/44: Eval mapcar and mapcan with partial-evaluated lists, Mattias Engdegård, 2019/03/26
- [elpa] externals/relint 34304b4 08/44: Add (provides) line to make file importable, Mattias Engdegård, 2019/03/26
- [elpa] externals/relint 62ca3d4 05/44: Slight performance improvement,
Mattias Engdegård <=
- [elpa] externals/relint 6ab713e 07/44: Reinstate erroneously removed line, Mattias Engdegård, 2019/03/26
- [elpa] externals/relint cb1fdc5 06/44: Add caret pointing out the error in the quoted regexp, Mattias Engdegård, 2019/03/26
- [elpa] externals/relint b4fc385 04/44: Rename trawl--batch to trawl-batch, Mattias Engdegård, 2019/03/26
- [elpa] externals/relint 0214845 01/44: Move to github, Mattias Engdegård, 2019/03/26
- [elpa] externals/relint 830f4bf 03/44: Allow use from batch mode, Mattias Engdegård, 2019/03/26
- [elpa] externals/relint 125b869 02/44: Try harder recovering from read errors, Mattias Engdegård, 2019/03/26