[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/vlf ee7409b 254/310: Tune batch size in more cases.
From: |
Stefan Monnier |
Subject: |
[elpa] externals/vlf ee7409b 254/310: Tune batch size in more cases. |
Date: |
Sat, 28 Nov 2020 00:33:26 -0500 (EST) |
branch: externals/vlf
commit ee7409bfa53fc5f9c28fa49241c7258496aede7c
Author: Andrey Kotlarski <m00naticus@gmail.com>
Commit: Andrey Kotlarski <m00naticus@gmail.com>
Tune batch size in more cases.
---
vlf-occur.el | 72 +++++++++++++++++++++++++++++++++++++++++------------------
vlf-search.el | 12 ++++++++--
2 files changed, 60 insertions(+), 24 deletions(-)
diff --git a/vlf-occur.el b/vlf-occur.el
index a867104..2227673 100644
--- a/vlf-occur.el
+++ b/vlf-occur.el
@@ -144,41 +144,69 @@ EVENT may hold details of the invocation."
(vlf-move-to-chunk chunk-start chunk-end)
(goto-char match-pos)))))
+(defun vlf-occur-other-buffer (regexp)
+ "Make whole file occur style index for REGEXP branching to new buffer.
+Prematurely ending indexing will still show what's found so far."
+ (let ((vlf-buffer (current-buffer))
+ (file buffer-file-name)
+ (batch-size vlf-batch-size)
+ (is-hexl (derived-mode-p 'hexl-mode))
+ (insert-bps vlf-tune-insert-bps)
+ (encode-bps vlf-tune-encode-bps)
+ (hexl-bps vlf-tune-hexl-bps)
+ (dehexlify-bps vlf-tune-dehexlify-bps))
+ (with-temp-buffer
+ (setq buffer-file-name file
+ buffer-file-truename file
+ buffer-undo-list t)
+ (set-buffer-modified-p nil)
+ (set (make-local-variable 'vlf-batch-size) batch-size)
+ (setq vlf-tune-insert-bps insert-bps
+ vlf-tune-encode-bps encode-bps)
+ (if is-hexl
+ (progn (setq vlf-tune-hexl-bps hexl-bps
+ vlf-tune-dehexlify-bps dehexlify-bps)
+ (vlf-tune-batch '(:hexl :dehexlify :insert :encode)))
+ (vlf-tune-batch '(:insert :encode)))
+ (vlf-mode 1)
+ (if is-hexl (vlf-tune-hexlify))
+ (goto-char (point-min))
+ (vlf-with-undo-disabled
+ (vlf-build-occur regexp vlf-buffer))
+ (setq insert-bps vlf-tune-insert-bps
+ encode-bps vlf-tune-encode-bps)
+ (if is-hexl
+ (setq insert-bps vlf-tune-insert-bps
+ encode-bps vlf-tune-encode-bps)))
+ (setq vlf-tune-insert-bps insert-bps
+ vlf-tune-encode-bps encode-bps)
+ (if is-hexl
+ (setq vlf-tune-insert-bps insert-bps
+ vlf-tune-encode-bps encode-bps))))
+
(defun vlf-occur (regexp)
"Make whole file occur style index for REGEXP.
Prematurely ending indexing will still show what's found so far."
(interactive (list (read-regexp "List lines matching regexp"
(if regexp-history
(car regexp-history)))))
- (if (buffer-modified-p) ;use temporary buffer not to interfere with
modifications
- (let ((vlf-buffer (current-buffer))
- (file buffer-file-name)
- (batch-size vlf-batch-size)
- (is-hexl (derived-mode-p 'hexl-mode)))
- (with-temp-buffer
- (setq buffer-file-name file
- buffer-file-truename file
- buffer-undo-list t)
- (set-buffer-modified-p nil)
- (set (make-local-variable 'vlf-batch-size) batch-size)
- (vlf-mode 1)
- (if is-hexl (vlf-tune-hexlify))
- (run-hook-with-args 'vlf-before-batch-functions 'occur)
- (goto-char (point-min))
- (vlf-with-undo-disabled
- (vlf-build-occur regexp vlf-buffer))
- (run-hook-with-args 'vlf-after-batch-functions 'occur)))
- (run-hook-with-args 'vlf-before-batch-functions 'occur)
+ (run-hook-with-args 'vlf-before-batch-functions 'occur)
+ (if (or (buffer-modified-p)
+ (< vlf-batch-size vlf-start-pos))
+ (vlf-occur-other-buffer regexp)
(let ((start-pos vlf-start-pos)
(end-pos vlf-end-pos)
(pos (point)))
+ (if (derived-mode-p 'hexl-mode)
+ (vlf-tune-batch '(:hexl :dehexlify :insert :encode))
+ (vlf-tune-batch '(:insert :encode)))
(vlf-with-undo-disabled
- (vlf-beginning-of-file)
+ (vlf-move-to-batch 0)
(goto-char (point-min))
(unwind-protect (vlf-build-occur regexp (current-buffer))
(vlf-move-to-chunk start-pos end-pos)
- (goto-char pos))))
- (run-hook-with-args 'vlf-after-batch-functions 'occur)))
+ (goto-char pos)))))
+ (run-hook-with-args 'vlf-after-batch-functions 'occur))
(defun vlf-build-occur (regexp vlf-buffer)
"Build occur style index for REGEXP over VLF-BUFFER."
diff --git a/vlf-search.el b/vlf-search.el
index 0c61898..36e8022 100644
--- a/vlf-search.el
+++ b/vlf-search.el
@@ -234,7 +234,11 @@ Search is performed chunk by chunk in `vlf-batch-size'
memory."
(+ start vlf-batch-size)))
(progress-reporter-update reporter start)))
(when (< n (- vlf-file-size end))
- (vlf-move-to-chunk-2 start end)
+ (if is-hexl
+ (vlf-tune-batch '(:hexl :dehexlify
+ :insert :encode))
+ (vlf-tune-batch '(:insert :encode)))
+ (vlf-move-to-chunk-2 start (+ start vlf-batch-size))
(goto-char (point-min))
(setq success (vlf-re-search "[\n\C-m]" n nil 0
reporter time)))))
@@ -260,7 +264,11 @@ Search is performed chunk by chunk in `vlf-batch-size'
memory."
(progress-reporter-update reporter
(- vlf-file-size end))))
(when (< n end)
- (vlf-move-to-chunk-2 start end)
+ (if is-hexl
+ (vlf-tune-batch '(:hexl :dehexlify
+ :insert :encode))
+ (vlf-tune-batch '(:insert :encode)))
+ (vlf-move-to-chunk-2 (- end vlf-batch-size) end)
(goto-char (point-max))
(setq success (vlf-re-search "[\n\C-m]" n t 0
reporter time))))))
- [elpa] externals/vlf d7766f2 209/310: Update documentation and mark autoloaded functions as interactive., (continued)
- [elpa] externals/vlf d7766f2 209/310: Update documentation and mark autoloaded functions as interactive., Stefan Monnier, 2020/11/28
- [elpa] externals/vlf 5d30eb4 206/310: Use single ediff pass to adjust borders. Protect against user, Stefan Monnier, 2020/11/28
- [elpa] externals/vlf ffac697 217/310: Keep undo list after occur or unsuccessful line search., Stefan Monnier, 2020/11/28
- [elpa] externals/vlf b05255b 220/310: Add hooks to run around chunk moves and batch operations. Don't err, Stefan Monnier, 2020/11/28
- [elpa] externals/vlf 557d751 236/310: Be more precise on restoring hexl-mode after chunk update has been, Stefan Monnier, 2020/11/28
- [elpa] externals/vlf ece554a 231/310: Wording., Stefan Monnier, 2020/11/28
- [elpa] externals/vlf 069b2f5 240/310: Replace operations with respective vlf-tune wrappers., Stefan Monnier, 2020/11/28
- [elpa] externals/vlf fb05030 241/310: Add basic tune strategies., Stefan Monnier, 2020/11/28
- [elpa] externals/vlf e18a05b 247/310: Add linear search for tuning and prefer smaller batches., Stefan Monnier, 2020/11/28
- [elpa] externals/vlf 48a014f 250/310: Fix write measuring and endless loop in nearby approximation., Stefan Monnier, 2020/11/28
- [elpa] externals/vlf ee7409b 254/310: Tune batch size in more cases.,
Stefan Monnier <=
- [elpa] externals/vlf 5651ee3 252/310: Rename vlf-tune-optimal to vlf-tune-batch., Stefan Monnier, 2020/11/28
- [elpa] externals/vlf 06b4f85 262/310: Respect disabled tune settings and move custom options., Stefan Monnier, 2020/11/28
- [elpa] externals/vlf 199209f 263/310: Fix vlf-tune-optimal-load with no optional arguments supplied., Stefan Monnier, 2020/11/28
- [elpa] externals/vlf 023ee70 267/310: Declare hexl functions to please byte compiler., Stefan Monnier, 2020/11/28
- [elpa] externals/vlf c3a308c 271/310: Optimize save performance over the temp file if such is used. Add, Stefan Monnier, 2020/11/28
- [elpa] externals/vlf ce13609 278/310: Fix vlf-ediff at the borders of hexl buffers., Stefan Monnier, 2020/11/28
- [elpa] externals/vlf f43ada1 282/310: Fix byte compilation warnings., Stefan Monnier, 2020/11/28
- [elpa] externals/vlf 305d802 280/310: Use shared profiling info for encode, write and hexl operations., Stefan Monnier, 2020/11/28
- [elpa] externals/vlf 5dd9e2c 281/310: Adjust address parts of hexlified buffer according to vlf-start-pos., Stefan Monnier, 2020/11/28
- [elpa] externals/vlf 68d6c1b 289/310: vlf-occur changes:, Stefan Monnier, 2020/11/28