branch: master
commit fae66ebe04f3501009010f0c4ba4bca3feb8b80a
Author: Artur Malabarba <bruce.connor...@gmail.com>
Commit: Artur Malabarba <bruce.connor...@gmail.com>

    Optimize syntax-ppss calls
---
 aggressive-indent.el |   19 +++++--------------
 1 files changed, 5 insertions(+), 14 deletions(-)

diff --git a/aggressive-indent.el b/aggressive-indent.el
index 72544c8..21353a4 100644
--- a/aggressive-indent.el
+++ b/aggressive-indent.el
@@ -188,9 +188,11 @@ commands will NOT be followed by a re-indent."
     (null (buffer-modified-p))
     (and (boundp 'smerge-mode) smerge-mode)
     (string-match "\\`[[:blank:]]*\n?\\'" (or (thing-at-point 'line) ""))
-    (and (not aggressive-indent-comments-too)
-         (aggressive-indent--in-comment-p))
-    (aggressive-indent--in-string-p))
+    (let ((sp (syntax-ppss)))
+      ;; Comments.
+      (or (and (not aggresive-indent-comments-too) (elt sp 4))
+          ;; Strings.
+          (elt sp 3))))
   "List of forms which prevent indentation when they evaluate to non-nil.
 This is for internal use only. For user customization, use
 `aggressive-indent-dont-indent-if' instead.")
@@ -346,17 +348,6 @@ Like `aggressive-indent-indent-region-and-on', but wrapped 
in a
   (push l -changed-list-left)
   (push r -changed-list-right))
 
-(defun -in-comment-p ()
-  "Return non-nil if point is inside a comment.
-Assumes that the syntax table is sufficient to find comments."
-  (nth 4 (syntax-ppss)))
-
-(defun -in-string-p ()
-  "Return non-nil if point is inside a string.
-Assumes that the syntax table is sufficient for recognizing
-strings."
-  (nth 3 (syntax-ppss)))
-
 
 ;;; Minor modes
 :autoload

Reply via email to