mirror of
https://github.com/m00natic/vlfi.git
synced 2025-01-18 03:55:31 +00:00
- don't load unnecessary data at the end of search or occur
- don't flood profile vector with approximations in linear search
This commit is contained in:
parent
61599a007f
commit
7b9befe81a
13
vlf-occur.el
13
vlf-occur.el
@ -294,12 +294,13 @@ Prematurely ending indexing will still show what's found so far."
|
||||
(setq end-of-file (= vlf-end-pos vlf-file-size))
|
||||
(unless end-of-file
|
||||
(vlf-tune-batch tune-types)
|
||||
(let ((batch-move (- vlf-end-pos batch-step)))
|
||||
(vlf-move-to-batch (if (or is-hexl
|
||||
(< match-end-pos
|
||||
batch-move))
|
||||
batch-move
|
||||
match-end-pos) t))
|
||||
(let* ((batch-move (- vlf-end-pos batch-step))
|
||||
(start (if (or is-hexl (< match-end-pos
|
||||
batch-move))
|
||||
batch-move
|
||||
match-end-pos)))
|
||||
(vlf-move-to-chunk start (+ start
|
||||
vlf-batch-size) t))
|
||||
(goto-char (if (or is-hexl
|
||||
(<= match-end-pos vlf-start-pos))
|
||||
(point-min)
|
||||
|
@ -79,14 +79,15 @@ Return t if search has been at least partially successful."
|
||||
((zerop vlf-start-pos)
|
||||
(throw 'end-of-file nil))
|
||||
(t (vlf-tune-batch tune-types)
|
||||
(let ((batch-move (- vlf-start-pos
|
||||
(- vlf-batch-size
|
||||
batch-step))))
|
||||
(vlf-move-to-batch
|
||||
(if (or is-hexl
|
||||
(<= batch-move match-start-pos))
|
||||
batch-move
|
||||
(- match-start-pos vlf-batch-size)) t))
|
||||
(let* ((batch-move (+ vlf-start-pos
|
||||
batch-step))
|
||||
(end (if (or is-hexl
|
||||
(<= batch-move
|
||||
match-start-pos))
|
||||
batch-move
|
||||
match-start-pos)))
|
||||
(vlf-move-to-chunk (- end vlf-batch-size)
|
||||
end t))
|
||||
(goto-char (if (or is-hexl
|
||||
(<= vlf-end-pos
|
||||
match-start-pos))
|
||||
@ -110,17 +111,21 @@ Return t if search has been at least partially successful."
|
||||
match-end-pos (+ vlf-start-pos
|
||||
(position-bytes
|
||||
(match-end 0))))))
|
||||
((= vlf-end-pos vlf-file-size)
|
||||
((>= vlf-end-pos vlf-file-size)
|
||||
(throw 'end-of-file nil))
|
||||
(t (vlf-tune-batch tune-types)
|
||||
(let ((batch-move (- vlf-end-pos batch-step)))
|
||||
(vlf-move-to-batch
|
||||
(if (or is-hexl
|
||||
(< match-end-pos batch-move))
|
||||
batch-move
|
||||
match-end-pos) t))
|
||||
(let* ((batch-move (- vlf-end-pos batch-step))
|
||||
(start (if (or is-hexl
|
||||
(< match-end-pos
|
||||
batch-move))
|
||||
batch-move
|
||||
match-end-pos)))
|
||||
(vlf-move-to-chunk start
|
||||
(+ start vlf-batch-size)
|
||||
t))
|
||||
(goto-char (if (or is-hexl
|
||||
(<= match-end-pos vlf-start-pos))
|
||||
(<= match-end-pos
|
||||
vlf-start-pos))
|
||||
(point-min)
|
||||
(or (byte-to-position
|
||||
(- match-end-pos
|
||||
|
@ -116,7 +116,7 @@ but don't change batch size. If t, measure and change."
|
||||
"Initialize measurement vector."
|
||||
(make-local-variable 'vlf-tune-max)
|
||||
(make-local-variable 'vlf-tune-step)
|
||||
(make-vector (/ vlf-tune-max vlf-tune-step) nil))
|
||||
(make-vector (1- (/ vlf-tune-max vlf-tune-step)) nil))
|
||||
|
||||
(defmacro vlf-tune-add-measurement (vec size time)
|
||||
"Add at an appropriate position in VEC new SIZE TIME measurement.
|
||||
@ -345,7 +345,7 @@ Optimize over TYPES up to MAX-IDX."
|
||||
(best-bps 0)
|
||||
(idx 0))
|
||||
(while (< idx max-idx)
|
||||
(let ((bps (vlf-tune-score types idx)))
|
||||
(let ((bps (vlf-tune-score types idx t)))
|
||||
(and bps (< best-bps bps)
|
||||
(setq best-idx idx
|
||||
best-bps bps)))
|
||||
|
Loading…
Reference in New Issue
Block a user