1
0
mirror of https://github.com/m00natic/vlfi.git synced 2024-10-05 18:30:51 +01:00

Optimize unconditional chunk loading and prefer it in more cases of

overlapping batch moves.
This commit is contained in:
Andrey Kotlarski 2014-12-13 18:46:57 +02:00
parent f4526a1492
commit 0fa624837a

View File

@ -140,8 +140,11 @@ bytes added to the end."
(if (consp hexl-undo-list) (if (consp hexl-undo-list)
(setq hexl-undo-list nil)) (setq hexl-undo-list nil))
(vlf-move-to-chunk-2 start end))) (vlf-move-to-chunk-2 start end)))
((or (and (<= start vlf-start-pos) (<= edit-end end)) ((and (not modified)
(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? ")) (y-or-n-p "Chunk modified, are you sure? "))
(run-hooks 'vlf-before-chunk-update) (run-hooks 'vlf-before-chunk-update)
(when (and hexl (not restore-hexl)) (when (and hexl (not restore-hexl))
@ -224,6 +227,15 @@ bytes added to the end."
Return number of bytes moved back for proper decoding and number of Return number of bytes moved back for proper decoding and number of
bytes added to the end." bytes added to the end."
(run-hooks 'vlf-before-chunk-update) (run-hooks 'vlf-before-chunk-update)
(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) (vlf-verify-size t)
(setq vlf-start-pos (max 0 start) (setq vlf-start-pos (max 0 start)
vlf-end-pos (min end vlf-file-size)) vlf-end-pos (min end vlf-file-size))
@ -232,12 +244,14 @@ bytes added to the end."
(pos (position-bytes (point)))) (pos (position-bytes (point))))
(vlf-with-undo-disabled (vlf-with-undo-disabled
(erase-buffer) (erase-buffer)
(if (derived-mode-p 'hexl-mode) (if is-hexl
(progn (vlf-tune-insert-file-contents-literally (progn (vlf-tune-insert-file-contents-literally
vlf-start-pos vlf-end-pos) vlf-start-pos vlf-end-pos)
(vlf-tune-hexlify)) (vlf-tune-hexlify))
(setq shifts (vlf-insert-file-contents vlf-start-pos (setq shifts (vlf-insert-file-contents vlf-start-pos
vlf-end-pos t t) vlf-end-pos
adjust-start
adjust-end)
vlf-start-pos (- vlf-start-pos (car shifts)) vlf-start-pos (- vlf-start-pos (car shifts))
vlf-end-pos (+ vlf-end-pos (cdr shifts))))) vlf-end-pos (+ vlf-end-pos (cdr shifts)))))
(goto-char (or (byte-to-position (+ pos (car shifts))) (goto-char (or (byte-to-position (+ pos (car shifts)))
@ -246,7 +260,7 @@ bytes added to the end."
(or (eq buffer-undo-list t) (or (eq buffer-undo-list t)
(setq buffer-undo-list nil)) (setq buffer-undo-list nil))
(run-hooks 'vlf-after-chunk-update) (run-hooks 'vlf-after-chunk-update)
shifts)) shifts)))
(defun vlf-insert-file-contents (start end adjust-start adjust-end (defun vlf-insert-file-contents (start end adjust-start adjust-end
&optional position) &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 Return number of bytes moved back for proper decoding and number of
bytes added to the end." bytes added to the end."
(setq adjust-start (and adjust-start (not (zerop start))) (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))) position (or position (point-min)))
(goto-char position) (goto-char position)
(let ((shift-start 0) (let ((shift-start 0)