emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] externals/vlf 7b9befe 275/310: - don't load unnecessary data at t


From: Stefan Monnier
Subject: [elpa] externals/vlf 7b9befe 275/310: - don't load unnecessary data at the end of search or occur
Date: Sat, 28 Nov 2020 00:33:31 -0500 (EST)

branch: externals/vlf
commit 7b9befe81a13301d1bde553c60f23d1fb75f73c1
Author: Andrey Kotlarski <m00naticus@gmail.com>
Commit: Andrey Kotlarski <m00naticus@gmail.com>

    - don't load unnecessary data at the end of search or occur
    - don't flood profile vector with approximations in linear search
---
 vlf-occur.el  | 13 +++++++------
 vlf-search.el | 37 +++++++++++++++++++++----------------
 vlf-tune.el   |  4 ++--
 3 files changed, 30 insertions(+), 24 deletions(-)

diff --git a/vlf-occur.el b/vlf-occur.el
index 73de8c2..4694655 100644
--- a/vlf-occur.el
+++ b/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)
diff --git a/vlf-search.el b/vlf-search.el
index 5be45b7..c60e631 100644
--- a/vlf-search.el
+++ b/vlf-search.el
@@ -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
diff --git a/vlf-tune.el b/vlf-tune.el
index ccbd56d..08bdd9d 100644
--- a/vlf-tune.el
+++ b/vlf-tune.el
@@ -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)))



reply via email to

[Prev in Thread] Current Thread [Next in Thread]