[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/vlf 0fa6248 288/310: Optimize unconditional chunk loadi
From: |
Stefan Monnier |
Subject: |
[elpa] externals/vlf 0fa6248 288/310: Optimize unconditional chunk loading and prefer it in more cases of |
Date: |
Sat, 28 Nov 2020 00:33:33 -0500 (EST) |
branch: externals/vlf
commit 0fa624837a2d19cd4abf2ded291be0911974f7ab
Author: Andrey Kotlarski <m00naticus@gmail.com>
Commit: Andrey Kotlarski <m00naticus@gmail.com>
Optimize unconditional chunk loading and prefer it in more cases of
overlapping batch moves.
---
vlf-base.el | 66 +++++++++++++++++++++++++++++++++++++------------------------
1 file changed, 40 insertions(+), 26 deletions(-)
diff --git a/vlf-base.el b/vlf-base.el
index 21a176a..42d1865 100644
--- a/vlf-base.el
+++ b/vlf-base.el
@@ -140,8 +140,11 @@ bytes added to the end."
(if (consp hexl-undo-list)
(setq hexl-undo-list nil))
(vlf-move-to-chunk-2 start end)))
- ((or (and (<= start vlf-start-pos) (<= edit-end end))
- (not modified)
+ ((and (not modified)
+ (not (consp buffer-undo-list)))
+ (vlf-move-to-chunk-2 start end))
+ ((or (not modified)
+ (and (<= start vlf-start-pos) (<= edit-end end))
(y-or-n-p "Chunk modified, are you sure? "))
(run-hooks 'vlf-before-chunk-update)
(when (and hexl (not restore-hexl))
@@ -224,29 +227,40 @@ bytes added to the end."
Return number of bytes moved back for proper decoding and number of
bytes added to the end."
(run-hooks 'vlf-before-chunk-update)
- (vlf-verify-size t)
- (setq vlf-start-pos (max 0 start)
- vlf-end-pos (min end vlf-file-size))
- (let ((shifts '(0 . 0)))
- (let ((inhibit-read-only t)
- (pos (position-bytes (point))))
- (vlf-with-undo-disabled
- (erase-buffer)
- (if (derived-mode-p 'hexl-mode)
- (progn (vlf-tune-insert-file-contents-literally
- vlf-start-pos vlf-end-pos)
- (vlf-tune-hexlify))
- (setq shifts (vlf-insert-file-contents vlf-start-pos
- vlf-end-pos t t)
- vlf-start-pos (- vlf-start-pos (car shifts))
- vlf-end-pos (+ vlf-end-pos (cdr shifts)))))
- (goto-char (or (byte-to-position (+ pos (car shifts)))
- (point-max))))
- (set-buffer-modified-p nil)
- (or (eq buffer-undo-list t)
- (setq buffer-undo-list nil))
- (run-hooks 'vlf-after-chunk-update)
- shifts))
+ (let ((adjust-start t)
+ (adjust-end t)
+ (is-hexl (derived-mode-p 'hexl-mode)))
+ (and (not is-hexl)
+ (verify-visited-file-modtime (current-buffer))
+ (setq adjust-start (and (/= start vlf-start-pos)
+ (/= start vlf-end-pos))
+ adjust-end (and (/= end vlf-start-pos)
+ (/= end vlf-end-pos))))
+ (vlf-verify-size t)
+ (setq vlf-start-pos (max 0 start)
+ vlf-end-pos (min end vlf-file-size))
+ (let ((shifts '(0 . 0)))
+ (let ((inhibit-read-only t)
+ (pos (position-bytes (point))))
+ (vlf-with-undo-disabled
+ (erase-buffer)
+ (if is-hexl
+ (progn (vlf-tune-insert-file-contents-literally
+ vlf-start-pos vlf-end-pos)
+ (vlf-tune-hexlify))
+ (setq shifts (vlf-insert-file-contents vlf-start-pos
+ vlf-end-pos
+ adjust-start
+ adjust-end)
+ vlf-start-pos (- vlf-start-pos (car shifts))
+ vlf-end-pos (+ vlf-end-pos (cdr shifts)))))
+ (goto-char (or (byte-to-position (+ pos (car shifts)))
+ (point-max))))
+ (set-buffer-modified-p nil)
+ (or (eq buffer-undo-list t)
+ (setq buffer-undo-list nil))
+ (run-hooks 'vlf-after-chunk-update)
+ shifts)))
(defun vlf-insert-file-contents (start end adjust-start adjust-end
&optional position)
@@ -257,7 +271,7 @@ Use buffer POSITION as start if given.
Return number of bytes moved back for proper decoding and number of
bytes added to the end."
(setq adjust-start (and adjust-start (not (zerop start)))
- adjust-end (and adjust-end (< end vlf-file-size))
+ adjust-end (and adjust-end (/= end vlf-file-size))
position (or position (point-min)))
(goto-char position)
(let ((shift-start 0)
- [elpa] externals/vlf 5651ee3 252/310: Rename vlf-tune-optimal to vlf-tune-batch., (continued)
- [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
- [elpa] externals/vlf 0fa6248 288/310: Optimize unconditional chunk loading and prefer it in more cases of,
Stefan Monnier <=
- [elpa] externals/vlf bd5f9ca 286/310: Back to using per buffer profiling for encode speed., Stefan Monnier, 2020/11/28
- [elpa] externals/vlf 726f50b 294/310: Fix byte-compilation warnings on install., Stefan Monnier, 2020/11/28
- [elpa] externals/vlf eaa3629 299/310: Fix cursor position after search, Stefan Monnier, 2020/11/28
- [elpa] externals/vlf ac1aa16 296/310: Standard naming for chunk update hooks., Stefan Monnier, 2020/11/28
- [elpa] externals/vlf cc02f25 306/310: Fix typos, Stefan Monnier, 2020/11/28