From 34e9aae4407aceb54c7b6bc4c9b4e3e10ec62314 Mon Sep 17 00:00:00 2001 From: Andrea Corallo Date: Sun, 27 Dec 2020 10:58:29 +0100 Subject: [PATCH] * 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 1927207db63..62e3c47ce3a 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)))) -- 2.39.5