branch: elpa/adoc-mode
commit 50b601dd92f99dd9534ff44de5f411480ca32b09
Author: Bozhidar Batsov <[email protected]>
Commit: Bozhidar Batsov <[email protected]>

    Avoid string allocation when measuring match lengths in title matching
    
    Use match position arithmetic instead of (length (match-string ...))
    to compare title text and underline lengths. This avoids allocating
    temporary strings just to measure their length.
---
 adoc-mode.el | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/adoc-mode.el b/adoc-mode.el
index dc40e935f4..cf64dcd959 100644
--- a/adoc-mode.el
+++ b/adoc-mode.el
@@ -1715,9 +1715,9 @@ text having adoc-reserved set to symbol `block-del'."
    `(lambda (end)
       (and adoc-enable-two-line-title
            (adoc-kwf-search ,(adoc-re-two-line-title del) end t)
-           (< (abs (- (length (match-string 2)) (length (match-string 3)))) 3)
+           (< (abs (- (- (match-end 2) (match-beginning 2)) (- (match-end 3) 
(match-beginning 3)))) 3)
            (or (not (numberp adoc-enable-two-line-title))
-               (not (equal adoc-enable-two-line-title (length (match-string 
2)))))
+               (not (equal adoc-enable-two-line-title (- (match-end 2) 
(match-beginning 2)))))
            (not (text-property-not-all (match-beginning 0) (match-end 0) 
'adoc-reserved nil))))
    ;; highlighers
    `(2 ,text-face t)

Reply via email to