[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/relint 458a920b46 06/17: Use a vector instead of list f
From: |
ELPA Syncer |
Subject: |
[elpa] externals/relint 458a920b46 06/17: Use a vector instead of list for complaint tuple |
Date: |
Thu, 1 Aug 2024 12:59:02 -0400 (EDT) |
branch: externals/relint
commit 458a920b465194be2348ddd9a81dd6a1552c7a1d
Author: Mattias EngdegÄrd <mattiase@acm.org>
Commit: Mattias EngdegÄrd <mattiase@acm.org>
Use a vector instead of list for complaint tuple
This is slightly faster and gives better type checking
---
relint-test.el | 37 +++++++++++++++++++------------------
relint.el | 57 +++++++++++++++++++++++++++++++++------------------------
2 files changed, 52 insertions(+), 42 deletions(-)
diff --git a/relint-test.el b/relint-test.el
index fd7f3c3e69..86d1ba9148 100644
--- a/relint-test.el
+++ b/relint-test.el
@@ -135,16 +135,17 @@ and a path."
(insert "(looking-at (make-string 2 ?^))\n")
(insert "(looking-at (concat \"ab\" \"cdef\" \"[gg]\"))\n")
(insert "(string-match \"[xy\" s)\n"))
- (should (equal
- (relint-buffer buf)
- '(("In call to looking-at: Repetition of repetition"
- 20 28 28 "broken**regexp" 7 7 warning)
- ("In call to looking-at: Unescaped literal `^'"
- 50 nil nil "^^" 1 1 warning)
- ("In call to looking-at: Duplicated `g' inside character
alternative"
- 82 105 105 "abcdef[gg]" 8 8 warning)
- ("In call to string-match: Unterminated character
alternative"
- 125 126 128 "[xy" 0 2 error)))))
+ (should
+ (equal
+ (relint-buffer buf)
+ '(["In call to looking-at: Repetition of repetition"
+ 20 28 28 "broken**regexp" 7 7 warning]
+ ["In call to looking-at: Unescaped literal `^'"
+ 50 nil nil "^^" 1 1 warning]
+ ["In call to looking-at: Duplicated `g' inside character
alternative"
+ 82 105 105 "abcdef[gg]" 8 8 warning]
+ ["In call to string-match: Unterminated character alternative"
+ 125 126 128 "[xy" 0 2 error]))))
(kill-buffer buf))))
(ert-deftest relint-buffer-huge ()
@@ -161,9 +162,9 @@ and a path."
(insert "(message \"goodbye\\! everyone!\")\n")
(let ((text-quoting-style 'grave))
(relint-buffer (current-buffer))))
- '(("Ineffective string escape `\\?'" nil 16 17 nil nil nil warning)
- ("Ineffective string escape `\\!'" nil 1288960 1288961 nil nil nil
- warning)))))
+ '(["Ineffective string escape `\\?'" nil 16 17 nil nil nil warning]
+ ["Ineffective string escape `\\!'" nil 1288960 1288961 nil nil nil
+ warning]))))
(ert-deftest relint-bad-hex-escape ()
;; Test the bad \x character escape warning. We do this separately because
@@ -182,10 +183,10 @@ and a path."
(should (equal
;; Ignore 'invalid escape char syntax' error.
(remove (assoc err diags) diags)
- '(("Character escape `\\x' not followed by hex digit"
- nil 15 16 nil nil nil warning)
- ("Character escape `\\x' not followed by hex digit"
- nil 19 20 nil nil nil warning)
+ '(["Character escape `\\x' not followed by hex digit"
+ nil 15 16 nil nil nil warning]
+ ["Character escape `\\x' not followed by hex digit"
+ nil 19 20 nil nil nil warning]
)))))
(kill-buffer buf))))
@@ -204,6 +205,6 @@ and a path."
"In call to looking-at: Possibly mistyped `:?' at start of group"))
(should (equal warnings
(and checks
- `((,msg 13 17 18 "\\(:?xy\\)+" 2 3 warning))))))))
+ `([,msg 13 17 18 "\\(:?xy\\)+" 2 3 warning])))))))
(provide 'relint-test)
diff --git a/relint.el b/relint.el
index fba546bcaf..764e1841bb 100644
--- a/relint.el
+++ b/relint.el
@@ -205,10 +205,17 @@ in case it occupies more than one position in the buffer."
(goto-char pos)
(1+ (current-column))))
-(cl-defun relint--output-report (error-buffer file
- (message expr-pos beg-pos end-pos
- str beg-idx end-idx severity))
- (let* ((beg (or beg-pos expr-pos))
+(defun relint--output-complaint (error-buffer file complaint)
+ ;; FIXME: Use accessors or destructuring
+ (let* ((message (aref complaint 0))
+ (expr-pos (aref complaint 1))
+ (beg-pos (aref complaint 2))
+ (end-pos (aref complaint 3))
+ (str (aref complaint 4))
+ (beg-idx (aref complaint 5))
+ (end-idx (aref complaint 6))
+ (severity (aref complaint 7))
+ (beg (or beg-pos expr-pos))
(end end-pos)
(beg-line (line-number-at-pos beg t))
(end-line (cond ((eq beg end) beg-line)
@@ -239,26 +246,28 @@ in case it occupies more than one position in the buffer."
(defun relint--output-complaints (buffer file complaints error-buffer)
(with-current-buffer buffer
(dolist (complaint complaints)
- (relint--output-report error-buffer file complaint))))
+ (relint--output-complaint error-buffer file complaint))))
(defvar relint--suppression-count)
(defvar relint--complaints
- ;; list of (MESSAGE EXPR-POS BEG-POS END-POS STR BEG-IDX END-IDX SEVERITY)
- ;; MESSAGE string of message
- ;; EXPR-POS position of expression or nil
- ;; BEG-POS exact first position of error or nil
- ;; END-POS exact last position of error or nil
- ;; STR string that is the subject of message
- ;; BEG-IDX starting index into STR or nil
- ;; END-IDX ending index into STR or nil
- ;; SEVERITY `error' or `warning'
+ ;; list of
+ ;; [MESSAGE EXPR-POS BEG-POS END-POS STRING BEG-IDX END-IDX SEVERITY]
+ ;; with fields:
+ ;; MESSAGE string of message
+ ;; EXPR-POS position of expression or nil
+ ;; BEG-POS exact first position of error or nil
+ ;; END-POS exact last position of error or nil
+ ;; STRING string inside which the complaint occurs or nil
+ ;; BEG-IDX starting index into STRING or nil
+ ;; END-IDX ending index into STRING or nil
+ ;; SEVERITY `error', `warning' or `info'
)
(defun relint--report (message expr-pos beg-pos end-pos
str beg-idx end-idx severity)
(if (relint--suppression (or expr-pos beg-pos) message)
(setq relint--suppression-count (1+ relint--suppression-count))
- (push (list message expr-pos beg-pos end-pos str beg-idx end-idx severity)
+ (push (vector message expr-pos beg-pos end-pos str beg-idx end-idx
severity)
relint--complaints)))
(defun relint--report-at-path (start-pos path msg str beg-idx end-idx severity)
@@ -2587,9 +2596,9 @@ The keys are sorted numerically, in ascending order.")
(cons
(relint--sort-with-key
;; Sort by error position if available, expression position otherwise.
- (lambda (x)
- (let ((expr-pos (nth 1 x))
- (error-pos (nth 2 x)))
+ (lambda (c)
+ (let ((expr-pos (aref c 1))
+ (error-pos (aref c 2)))
(or error-pos expr-pos)))
complaints)
relint--suppression-count))))
@@ -2750,12 +2759,12 @@ Each element in the returned list has the form
where
- MESSAGE is the message string
- EXPR-POS the location of the flawed expression or nil
- BEG-POS and END-POS the exact boundaries of the error or nil if unavailable
- STRING is nil or a string to which the message pertains
- BEG-IDX and END-IDX are bounds in STRING or nil,
- and SEVERITY is `error' or `warning'.
+ MESSAGE the message string
+ EXPR-POS the location of the flawed expression or nil
+ BEG-POS, END-POS exact bounds in the buffer of the error, or nil
+ STRING nil or a string to which the message pertains
+ BEG-IDX, END-IDX bounds in STRING or nil
+ SEVERITY `error', `warning' or `info'
The intent is that BEG-POS..END-POS is the buffer range that
corresponds to STRING at BEG-IDX..END-IDX, if such a location can be
- [elpa] externals/relint updated (9cb20f89ce -> 38c0468a05), ELPA Syncer, 2024/08/01
- [elpa] externals/relint d0bb526e77 02/17: Faster (nonrecursive) traversal of let* bindings, ELPA Syncer, 2024/08/01
- [elpa] externals/relint 89e15852b1 01/17: Move version history to separate NEWS file, ELPA Syncer, 2024/08/01
- [elpa] externals/relint 7abad19169 03/17: Adapt to xr changes: ranged diagnostics with severity field, ELPA Syncer, 2024/08/01
- [elpa] externals/relint 61724881c3 10/17: Use a defstruct for diag objects instead of raw vectors, ELPA Syncer, 2024/08/01
- [elpa] externals/relint 38c0468a05 17/17: Github CI: ignore changes to NEWS in actions, ELPA Syncer, 2024/08/01
- [elpa] externals/relint 35a2bc31c8 11/17: Simplify: remove expr-pos from diag object, ELPA Syncer, 2024/08/01
- [elpa] externals/relint 458a920b46 06/17: Use a vector instead of list for complaint tuple,
ELPA Syncer <=
- [elpa] externals/relint 79ba1f0183 14/17: Require Emacs 27 or newer, ELPA Syncer, 2024/08/01
- [elpa] externals/relint 8cd09d69ae 16/17: NEWS entry for upcoming version 2.0, ELPA Syncer, 2024/08/01
- [elpa] externals/relint 94b23171f0 12/17: Add pos-type field in diag object, ELPA Syncer, 2024/08/01
- [elpa] externals/relint 5c63370936 04/17: Adapt to xr grouped diagnostics, ELPA Syncer, 2024/08/01
- [elpa] externals/relint caea432bb4 09/17: Better string range highlighting in output, ELPA Syncer, 2024/08/01
- [elpa] externals/relint 8e8db0e4b3 07/17: Simplify: xr-lint no longer signals errors, ELPA Syncer, 2024/08/01
- [elpa] externals/relint bc17dfcd16 05/17: Use ranges in relint's own diags, ELPA Syncer, 2024/08/01
- [elpa] externals/relint 9495957270 08/17: Grouped diagnostics, handle 'info' messages, ELPA Syncer, 2024/08/01
- [elpa] externals/relint dfd0e30ac8 13/17: Expose the relint-diag object to the user, ELPA Syncer, 2024/08/01
- [elpa] externals/relint 61c0dd607f 15/17: Fix \x test in emacs 30, ELPA Syncer, 2024/08/01