[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/vlf 5c604c4 211/310: Optimize vlf-goto-line not to deco
From: |
Stefan Monnier |
Subject: |
[elpa] externals/vlf 5c604c4 211/310: Optimize vlf-goto-line not to decode batches as long as possible. |
Date: |
Sat, 28 Nov 2020 00:33:17 -0500 (EST) |
branch: externals/vlf
commit 5c604c48a4ef96d2fdcfd40c47a2aade2daa4acf
Author: Andrey Kotlarski <m00naticus@gmail.com>
Commit: Andrey Kotlarski <m00naticus@gmail.com>
Optimize vlf-goto-line not to decode batches as long as possible.
---
vlf-search.el | 51 +++++++++++++++++++++++++++++++++++++++++----------
1 file changed, 41 insertions(+), 10 deletions(-)
diff --git a/vlf-search.el b/vlf-search.el
index 0db5ba5..495fa91 100644
--- a/vlf-search.el
+++ b/vlf-search.el
@@ -175,22 +175,53 @@ Search is performed chunk by chunk in `vlf-batch-size'
memory."
"Go to line N. If N is negative, count from the end of file."
(interactive (if (vlf-no-modifications)
(list (read-number "Go to line: "))))
+ (vlf-verify-size)
(let ((start-pos vlf-start-pos)
(end-pos vlf-end-pos)
(pos (point))
(success nil))
(unwind-protect
(if (< 0 n)
- (progn (vlf-beginning-of-file)
- (goto-char (point-min))
- (setq success (vlf-re-search "[\n\C-m]" (1- n)
- nil 0)))
- (vlf-end-of-file)
- (goto-char (point-max))
- (setq success (vlf-re-search "[\n\C-m]" (- n) t 0)))
- (if success
- (message "Onto line %s" n)
- (vlf-move-to-chunk start-pos end-pos)
+ (let ((start 0)
+ (end (min vlf-batch-size vlf-file-size))
+ (inhibit-read-only t))
+ (setq n (1- n))
+ (vlf-with-undo-disabled
+ (while (and (< (- end start) n)
+ (< n (- vlf-file-size start)))
+ (erase-buffer)
+ (insert-file-contents-literally buffer-file-name
+ nil start end)
+ (goto-char (point-min))
+ (while (re-search-forward "[\n\C-m]" nil t)
+ (setq n (1- n)))
+ (vlf-verify-size)
+ (setq start end
+ end (min vlf-file-size
+ (+ start vlf-batch-size))))
+ (when (< n (- vlf-file-size end))
+ (vlf-move-to-chunk-2 start end)
+ (goto-char (point-min))
+ (setq success (vlf-re-search "[\n\C-m]" n nil 0)))))
+ (let ((start (max 0 (- vlf-file-size vlf-batch-size)))
+ (end vlf-file-size)
+ (inhibit-read-only t))
+ (vlf-with-undo-disabled
+ (while (and (< (- end) n) (< n (- start end)))
+ (erase-buffer)
+ (insert-file-contents-literally buffer-file-name nil
+ start end)
+ (goto-char (point-max))
+ (while (re-search-backward "[\n\C-m]" nil t)
+ (setq n (1+ n)))
+ (setq end start
+ start (max 0 (- end vlf-batch-size))))
+ (when (< (- end) n)
+ (vlf-move-to-chunk-2 start end)
+ (goto-char (point-max))
+ (setq success (vlf-re-search "[\n\C-m]" (- n) t 0))))))
+ (unless success
+ (vlf-move-to-chunk-2 start-pos end-pos)
(goto-char pos)))))
(provide 'vlf-search)
- [elpa] externals/vlf ea46386 168/310: Don't apply VLF by default over image and pdf files., (continued)
- [elpa] externals/vlf ea46386 168/310: Don't apply VLF by default over image and pdf files., Stefan Monnier, 2020/11/28
- [elpa] externals/vlf 2470fc0 181/310: Fix vlf-shift-undo-list to reverse resulting list., Stefan Monnier, 2020/11/28
- [elpa] externals/vlf 161a4ec 184/310: Prevent inserting of too small file regions for GNU Emacs later than, Stefan Monnier, 2020/11/28
- [elpa] externals/vlf 95e6259 188/310: Add convenience macro to disable VLF application during execution of, Stefan Monnier, 2020/11/28
- [elpa] externals/vlf 66db665 189/310: Fix follow functionality and explicitly set variable as buffer local., Stefan Monnier, 2020/11/28
- [elpa] externals/vlf 38e8f6c 199/310: Update file size when moving to end of buffer., Stefan Monnier, 2020/11/28
- [elpa] externals/vlf 47c154c 194/310: Fix detection of good chunk start., Stefan Monnier, 2020/11/28
- [elpa] externals/vlf 1a1ce27 212/310: Add progress reporters for the optimized part of line search., Stefan Monnier, 2020/11/28
- [elpa] externals/vlf e747de4 204/310: Unify and optimize deletion., Stefan Monnier, 2020/11/28
- [elpa] externals/vlf 9510c70 215/310: Retry decoding when the initial attempt seems wrong., Stefan Monnier, 2020/11/28
- [elpa] externals/vlf 5c604c4 211/310: Optimize vlf-goto-line not to decode batches as long as possible.,
Stefan Monnier <=
- [elpa] externals/vlf a71ee32 216/310: Skip adjustment in some cases of overlapping chunk., Stefan Monnier, 2020/11/28
- [elpa] externals/vlf b235cf9 224/310: Execute vlf-after-batch-functions hook even on user quit command before, Stefan Monnier, 2020/11/28
- [elpa] externals/vlf 6bb60b7 225/310: Fix hexl scroll up called from scroll down behavior., Stefan Monnier, 2020/11/28
- [elpa] externals/vlf 924d6b1 219/310: Revert to using insert-file-contents instead of manual decoding., Stefan Monnier, 2020/11/28
- [elpa] externals/vlf 859c1e4 223/310: Fix hook names., Stefan Monnier, 2020/11/28
- [elpa] externals/vlf 694d1de 235/310: Allow vlf-occur results be saved to file and later reused., Stefan Monnier, 2020/11/28
- [elpa] externals/vlf 274c5ab 233/310: Perform search, occur and ediff operations over hexl content instead, Stefan Monnier, 2020/11/28
- [elpa] externals/vlf d9cc6fb 264/310: Fix vlf-tune-optimal-load in case best value prunes slower times leaving, Stefan Monnier, 2020/11/28
- [elpa] externals/vlf d1a6800 284/310: Move vlf information from buffer name to the mode line., Stefan Monnier, 2020/11/28
- [elpa] externals/vlf a7be713 283/310: Set vlf-tune-max with proper value in case RAM size is wrongly, Stefan Monnier, 2020/11/28