branch: externals/phps-mode
commit f79b6118a45ba74ceca4d294202c8855c35f00b6
Author: Christian Johansson <[email protected]>
Commit: Christian Johansson <[email protected]>
Optimization of string indentation function
---
phps-mode-indent.el | 17 +++--------------
1 file changed, 3 insertions(+), 14 deletions(-)
diff --git a/phps-mode-indent.el b/phps-mode-indent.el
index e6acb397b0..18792d2411 100644
--- a/phps-mode-indent.el
+++ b/phps-mode-indent.el
@@ -12,20 +12,9 @@
(defun phps-mode-indent--string-indentation (string)
"Count indentation of STRING."
- (let ((occurences 0)
- (start 0)
- (length (length string)))
- (when (< start length)
- (let ((match-start (string-match "[\t ]" string start)))
- (while (and
- match-start
- (= match-start start))
- (setq occurences (1+ occurences))
- (setq start (match-end 0))
- (if (< start length)
- (setq match-start (string-match "[\t ]" string start))
- (setq match-start nil)))))
- occurences))
+ (if (string-match "\\(^[\t ]+\\)" string)
+ (length (substring string (match-beginning 0) (match-end 0)))
+ 0))
(defun phps-mode-indent-line (&optional initial-point)
"Apply alternative indentation at INITIAL-POINT here."