mirror of
https://github.com/m00natic/vlfi.git
synced 2025-01-31 02:00:47 +00:00
Optimize chunk save buffers for multiple insert/erase operations.
This commit is contained in:
parent
9fad430601
commit
4cbefdeeca
11
vlfi.el
11
vlfi.el
@ -474,11 +474,18 @@ Save anyway? ")))
|
|||||||
(vlfi-mode)
|
(vlfi-mode)
|
||||||
t))
|
t))
|
||||||
|
|
||||||
|
(defun vlfi-prepare-write-buffer ()
|
||||||
|
"Optimize buffer for a lot of insert/erasure."
|
||||||
|
(setq delay-mode-hooks t)
|
||||||
|
(fundamental-mode)
|
||||||
|
(buffer-disable-undo))
|
||||||
|
|
||||||
(defun vlfi-file-shift-back (size-change)
|
(defun vlfi-file-shift-back (size-change)
|
||||||
"Shift file contents SIZE-CHANGE bytes back."
|
"Shift file contents SIZE-CHANGE bytes back."
|
||||||
(let ((coding-system buffer-file-coding-system))
|
(let ((coding-system buffer-file-coding-system))
|
||||||
(write-region nil nil buffer-file-name vlfi-start-pos t)
|
(write-region nil nil buffer-file-name vlfi-start-pos t)
|
||||||
(setq buffer-file-coding-system nil)
|
(setq buffer-file-coding-system nil)
|
||||||
|
(vlfi-prepare-write-buffer)
|
||||||
(let ((read-start-pos vlfi-end-pos)
|
(let ((read-start-pos vlfi-end-pos)
|
||||||
(reporter (make-progress-reporter "Adjusting file content"
|
(reporter (make-progress-reporter "Adjusting file content"
|
||||||
vlfi-end-pos
|
vlfi-end-pos
|
||||||
@ -516,8 +523,10 @@ Done by saving content up front and then writing previous batch."
|
|||||||
(coding-system buffer-file-coding-system))
|
(coding-system buffer-file-coding-system))
|
||||||
(let ((file buffer-file-name))
|
(let ((file buffer-file-name))
|
||||||
(set-buffer temp-buffer)
|
(set-buffer temp-buffer)
|
||||||
(setq buffer-file-name file))
|
(setq buffer-file-name file)
|
||||||
|
(vlfi-prepare-write-buffer))
|
||||||
(set-buffer vlfi-buffer)
|
(set-buffer vlfi-buffer)
|
||||||
|
(vlfi-prepare-write-buffer)
|
||||||
(let ((read-buffer temp-buffer)
|
(let ((read-buffer temp-buffer)
|
||||||
(write-buffer vlfi-buffer)
|
(write-buffer vlfi-buffer)
|
||||||
(size (+ vlfi-batch-size size-change))
|
(size (+ vlfi-batch-size size-change))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user