[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/rust-mode eca55c0 451/486: Check for -> and => early in ru
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/rust-mode eca55c0 451/486: Check for -> and => early in rust-ordinary-lt-gt-p |
Date: |
Sat, 7 Aug 2021 09:26:12 -0400 (EDT) |
branch: elpa/rust-mode
commit eca55c068eb90aa5e1f36c6b31de589ce1df2ff1
Author: Trevor Spiteri <tspiteri@ieee.org>
Commit: Nathan Moreau <nathan.moreau@m4x.org>
Check for -> and => early in rust-ordinary-lt-gt-p
Since the check for -> and => is very cheap, move it up in
rust-ordinary-lt-gt-p potentially saving much more expensive checks.
Also use simple equality check instead of regex function looking-at
for checking following character.
---
rust-mode.el | 28 +++++++++++++++-------------
1 file changed, 15 insertions(+), 13 deletions(-)
diff --git a/rust-mode.el b/rust-mode.el
index 6a0c1b5..925a9c8 100644
--- a/rust-mode.el
+++ b/rust-mode.el
@@ -1132,6 +1132,10 @@ should be considered a paired angle bracket."
;; If matching is turned off suppress all of them
((not rust-match-angle-brackets) t)
+ ;; This is a cheap check so we do it early.
+ ;; Don't treat the > in -> or => as an angle bracket
+ ((and (= (following-char) ?>) (memq (preceding-char) '(?- ?=))) t)
+
;; We don't take < or > in strings or comments to be angle brackets
((rust-in-str-or-cmnt) t)
@@ -1141,23 +1145,21 @@ should be considered a paired angle bracket."
;; as angle brackets it won't mess up any paren balancing.
((rust-in-macro) t)
- ((looking-at "<")
+ ((= (following-char) ?<)
(rust-is-lt-char-operator))
- ((looking-at ">")
- (cond
- ;; Don't treat the > in -> or => as an angle bracket
- ((member (char-before (point)) '(?- ?=)) t)
+ ;; Since rust-ordinary-lt-gt-p is called only when either < or > are at the
point,
+ ;; we know that the following char must be > in the clauses below.
- ;; If we are at top level and not in any list, it can't be a closing
- ;; angle bracket
- ((>= 0 (rust-paren-level)) t)
+ ;; If we are at top level and not in any list, it can't be a closing
+ ;; angle bracket
+ ((>= 0 (rust-paren-level)) t)
- ;; Otherwise, treat the > as a closing angle bracket if it would
- ;; match an opening one
- ((save-excursion
- (backward-up-list)
- (not (looking-at "<"))))))))
+ ;; Otherwise, treat the > as a closing angle bracket if it would
+ ;; match an opening one
+ ((save-excursion
+ (backward-up-list)
+ (/= (following-char) ?<)))))
(defun rust-mode-syntactic-face-function (state)
"Return face which distinguishes doc and normal comments in the given syntax
STATE."
- [nongnu] elpa/rust-mode e006788 474/486: Add .dir-locals.el, (continued)
- [nongnu] elpa/rust-mode e006788 474/486: Add .dir-locals.el, ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode 7fdb9c2 450/486: Use <kbd> to indicate keyboard input in README (#375), ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode d211e68 453/486: Fix various byte compilation warnings in rust-mode-tests.el., ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode bded667 457/486: Add missing ‘require’ form., ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode 139a658 482/486: Create rust-rustfmt.el from existing code, ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode 494d59f 486/486: Make most additional libraries optional, ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode 9f3d8cf 432/486: rust format buffer now saves position across multiple frames (#348), ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode 6f1abc3 438/486: Expand README to include more information about features (#358), ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode e04e485 441/486: rustc-compilation-regexps: handle `note` case as compilation-info., ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode 39f32cc 447/486: In emacs >= 26.2, use replace-buffer-contents after formatting, ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode eca55c0 451/486: Check for -> and => early in rust-ordinary-lt-gt-p,
ELPA Syncer <=
- [nongnu] elpa/rust-mode ca7d99c 469/486: Set default directory when compiling., ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode c5c7ed3 471/486: Update README.md, ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode 4e394ac 475/486: Add Makefile, ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode 09b4320 476/486: test: Suppress some noisy messages, ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode afeddec 325/486: Merge pull request #224 from tromey/beginning-of-defun, ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode 7fd78f0 444/486: rust-goto-format-problem: make sure to always just to a buffer that exists., ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode 9e03890 478/486: Create rust-compile.el from existing code, ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode 41642f0 481/486: rust-end-of-string: Move definition, ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode d548425 483/486: Create rust-playpen.el from existing code, ELPA Syncer, 2021/08/07
- [nongnu] elpa/rust-mode eb5270b 437/486: rust-before-save-hook: log errors., ELPA Syncer, 2021/08/07