Function: s-shared-end
s-shared-end is a byte-compiled function defined in s.el.
Signature
(s-shared-end S1 S2)
Documentation
Returns the longest suffix S1 and S2 have in common.
Source Code
;; Defined in ~/.emacs.d/elpa/s-20220902.1511/s.el
(defun s-shared-end (s1 s2)
"Returns the longest suffix S1 and S2 have in common."
(declare (pure t) (side-effect-free t))
(let* ((l1 (length s1))
(l2 (length s2))
(search-length (min l1 l2))
(i 0))
(while (and (< i search-length)
(= (aref s1 (- l1 i 1)) (aref s2 (- l2 i 1))))
(setq i (1+ i)))
;; If I is 0, then it means that there's no common suffix between
;; S1 and S2.
;;
;; However, since (substring s (- 0)) will return the whole
;; string, `s-shared-end' should simply return the empty string
;; when I is 0.
(if (zerop i)
""
(substring s1 (- i)))))