@@ -194,26 +194,21 @@ which can be passed directly to ‘clang-format’."
194194 ; ; Find and collect all diff lines.
195195 ; ; We are matching something like:
196196 ; ; "@@ -80 +80 @@" or "@@ -80,2 +80,2 @@"
197- (let ((diff-lines-re
198- " ^@@\s -[0-9,]+\s \\ +\\ ([0-9]+\\ )\\ (,\\ ([0-9]+\\ )\\ )?\s @@$" )
199- (index 0 )
200- (all-lines
201- (buffer-substring-no-properties (point-min ) (point-max ))))
202- ; ; We are essentially doing (while (re-search-forward ...) ...)
203- ; ; here. We are doing it by hand with (string-match ...) as it
204- ; ; is notably faster (about 50%).
205- (setq index (string-match diff-lines-re all-lines))
206- (while index
207- (let ((match1 (string-to-number (match-string 1 all-lines)))
208- (match3 (if (match-string 3 all-lines)
209- (string-to-number (match-string 3 all-lines))
210- nil )))
211- (push (format
212- " --lines=%d:%d"
213- match1
214- (if match3 (+ match1 match3) match1))
215- diff-lines))
216- (setq index (string-match diff-lines-re all-lines (+ index 1 )))))
197+ (goto-char (point-min ))
198+ (while (re-search-forward
199+ " ^@@\s -[0-9,]+\s \\ +\\ ([0-9]+\\ )\\ (,\\ ([0-9]+\\ )\\ )?\s @@$"
200+ nil
201+ t
202+ 1 )
203+ (let ((match1 (string-to-number (match-string 1 )))
204+ (match3 (if (match-string 3 )
205+ (string-to-number (match-string 3 ))
206+ nil )))
207+ (push (format
208+ " --lines=%d:%d"
209+ match1
210+ (if match3 (+ match1 match3) match1))
211+ diff-lines)))
217212 (nreverse diff-lines))
218213 ; ; Any return != 0 && != 1 indicates some level of error.
219214 (t
0 commit comments