mirror of
https://github.com/m00natic/vlfi.git
synced 2025-01-18 12:05: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))
|
(setq end-of-file (= vlf-end-pos vlf-file-size))
|
||||||
(unless end-of-file
|
(unless end-of-file
|
||||||
(vlf-tune-batch tune-types)
|
(vlf-tune-batch tune-types)
|
||||||
(let ((batch-move (- vlf-end-pos batch-step)))
|
(let* ((batch-move (- vlf-end-pos batch-step))
|
||||||
(vlf-move-to-batch (if (or is-hexl
|
(start (if (or is-hexl (< match-end-pos
|
||||||
(< match-end-pos
|
batch-move))
|
||||||
batch-move))
|
batch-move
|
||||||
batch-move
|
match-end-pos)))
|
||||||
match-end-pos) t))
|
(vlf-move-to-chunk start (+ start
|
||||||
|
vlf-batch-size) t))
|
||||||
(goto-char (if (or is-hexl
|
(goto-char (if (or is-hexl
|
||||||
(<= match-end-pos vlf-start-pos))
|
(<= match-end-pos vlf-start-pos))
|
||||||
(point-min)
|
(point-min)
|
||||||
|
@ -79,14 +79,15 @@ Return t if search has been at least partially successful."
|
|||||||
((zerop vlf-start-pos)
|
((zerop vlf-start-pos)
|
||||||
(throw 'end-of-file nil))
|
(throw 'end-of-file nil))
|
||||||
(t (vlf-tune-batch tune-types)
|
(t (vlf-tune-batch tune-types)
|
||||||
(let ((batch-move (- vlf-start-pos
|
(let* ((batch-move (+ vlf-start-pos
|
||||||
(- vlf-batch-size
|
batch-step))
|
||||||
batch-step))))
|
(end (if (or is-hexl
|
||||||
(vlf-move-to-batch
|
(<= batch-move
|
||||||
(if (or is-hexl
|
match-start-pos))
|
||||||
(<= batch-move match-start-pos))
|
batch-move
|
||||||
batch-move
|
match-start-pos)))
|
||||||
(- match-start-pos vlf-batch-size)) t))
|
(vlf-move-to-chunk (- end vlf-batch-size)
|
||||||
|
end t))
|
||||||
(goto-char (if (or is-hexl
|
(goto-char (if (or is-hexl
|
||||||
(<= vlf-end-pos
|
(<= vlf-end-pos
|
||||||
match-start-pos))
|
match-start-pos))
|
||||||
@ -110,17 +111,21 @@ Return t if search has been at least partially successful."
|
|||||||
match-end-pos (+ vlf-start-pos
|
match-end-pos (+ vlf-start-pos
|
||||||
(position-bytes
|
(position-bytes
|
||||||
(match-end 0))))))
|
(match-end 0))))))
|
||||||
((= vlf-end-pos vlf-file-size)
|
((>= vlf-end-pos vlf-file-size)
|
||||||
(throw 'end-of-file nil))
|
(throw 'end-of-file nil))
|
||||||
(t (vlf-tune-batch tune-types)
|
(t (vlf-tune-batch tune-types)
|
||||||
(let ((batch-move (- vlf-end-pos batch-step)))
|
(let* ((batch-move (- vlf-end-pos batch-step))
|
||||||
(vlf-move-to-batch
|
(start (if (or is-hexl
|
||||||
(if (or is-hexl
|
(< match-end-pos
|
||||||
(< match-end-pos batch-move))
|
batch-move))
|
||||||
batch-move
|
batch-move
|
||||||
match-end-pos) t))
|
match-end-pos)))
|
||||||
|
(vlf-move-to-chunk start
|
||||||
|
(+ start vlf-batch-size)
|
||||||
|
t))
|
||||||
(goto-char (if (or is-hexl
|
(goto-char (if (or is-hexl
|
||||||
(<= match-end-pos vlf-start-pos))
|
(<= match-end-pos
|
||||||
|
vlf-start-pos))
|
||||||
(point-min)
|
(point-min)
|
||||||
(or (byte-to-position
|
(or (byte-to-position
|
||||||
(- match-end-pos
|
(- match-end-pos
|
||||||
|
@ -116,7 +116,7 @@ but don't change batch size. If t, measure and change."
|
|||||||
"Initialize measurement vector."
|
"Initialize measurement vector."
|
||||||
(make-local-variable 'vlf-tune-max)
|
(make-local-variable 'vlf-tune-max)
|
||||||
(make-local-variable 'vlf-tune-step)
|
(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)
|
(defmacro vlf-tune-add-measurement (vec size time)
|
||||||
"Add at an appropriate position in VEC new SIZE TIME measurement.
|
"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)
|
(best-bps 0)
|
||||||
(idx 0))
|
(idx 0))
|
||||||
(while (< idx max-idx)
|
(while (< idx max-idx)
|
||||||
(let ((bps (vlf-tune-score types idx)))
|
(let ((bps (vlf-tune-score types idx t)))
|
||||||
(and bps (< best-bps bps)
|
(and bps (< best-bps bps)
|
||||||
(setq best-idx idx
|
(setq best-idx idx
|
||||||
best-bps bps)))
|
best-bps bps)))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user