emacs-diffs
[Top][All Lists]
Advanced

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

feature/native-comp 34e9aae 1/4: * Add comp-cstr-greatest-in-range comp-


From: Andrea Corallo
Subject: feature/native-comp 34e9aae 1/4: * Add comp-cstr-greatest-in-range comp-cstr-smallest-in-range
Date: Sun, 27 Dec 2020 15:53:38 -0500 (EST)

branch: feature/native-comp
commit 34e9aae4407aceb54c7b6bc4c9b4e3e10ec62314
Author: Andrea Corallo <akrl@sdf.org>
Commit: Andrea Corallo <akrl@sdf.org>

    * Add comp-cstr-greatest-in-range comp-cstr-smallest-in-range
    
        * lisp/emacs-lisp/comp-cstr.el (comp-cstr-smallest-in-range)
        (comp-cstr-greatest-in-range): New function.
        (comp-cstr->, comp-cstr->=, comp-cstr-<, comp-cstr-<=): Make use of.
---
 lisp/emacs-lisp/comp-cstr.el | 16 ++++++++++++----
 1 file changed, 12 insertions(+), 4 deletions(-)

diff --git a/lisp/emacs-lisp/comp-cstr.el b/lisp/emacs-lisp/comp-cstr.el
index 1927207..62e3c47 100644
--- a/lisp/emacs-lisp/comp-cstr.el
+++ b/lisp/emacs-lisp/comp-cstr.el
@@ -288,6 +288,14 @@ Return them as multiple value."
    ((eq y '-) nil)
    (t (< x y))))
 
+(defsubst comp-cstr-smallest-in-range (range)
+  "Smallest entry in RANGE."
+  (caar range))
+
+(defsubst comp-cstr-greatest-in-range (range)
+  "Greater entry in RANGE."
+  (cdar (last range)))
+
 (defun comp-range-union (&rest ranges)
   "Combine integer intervals RANGES by union set operation."
   (cl-loop
@@ -687,7 +695,7 @@ SRC can be either a comp-cstr or an integer."
            (if (integerp src)
                `((,(1+ src) . +))
              (when-let* ((range (range src))
-                         (low (cdar (last range)))
+                         (low (comp-cstr-greatest-in-range range))
                          (okay (integerp low)))
                `((,(1+ low) . +))))))
       (comp-cstr-set-cmp-range dst old-dst ext-range))))
@@ -700,7 +708,7 @@ SRC can be either a comp-cstr or an integer."
            (if (integerp src)
                `((,src . +))
              (when-let* ((range (range src))
-                         (low (cdar (last range)))
+                         (low (comp-cstr-greatest-in-range range))
                          (okay (integerp low)))
                `((,low . +))))))
       (comp-cstr-set-cmp-range dst old-dst ext-range))))
@@ -713,7 +721,7 @@ SRC can be either a comp-cstr or an integer."
            (if (integerp src)
                `((- . ,(1- src)))
              (when-let* ((range (range src))
-                         (low (caar (last range)))
+                         (low (comp-cstr-smallest-in-range range))
                          (okay (integerp low)))
                `((- . ,(1- low)))))))
       (comp-cstr-set-cmp-range dst old-dst ext-range))))
@@ -726,7 +734,7 @@ SRC can be either a comp-cstr or an integer."
            (if (integerp src)
                `((- . ,src))
              (when-let* ((range (range src))
-                         (low (caar (last range)))
+                         (low (comp-cstr-smallest-in-range range))
                          (okay (integerp low)))
                `((- . ,low))))))
       (comp-cstr-set-cmp-range dst old-dst ext-range))))



reply via email to

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