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

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

[elpa] externals/trie e505b47 039/111: Pass equality function constructe


From: Stefan Monnier
Subject: [elpa] externals/trie e505b47 039/111: Pass equality function constructed from trie comparison function to tNFA functions
Date: Mon, 14 Dec 2020 11:35:16 -0500 (EST)

branch: externals/trie
commit e505b47b24dee30767bffc30ca26e7460e0aff31
Author: Toby Cubitt <toby-predictive@dr-qubit.org>
Commit: tsc25 <toby-predictive@dr-qubit.org>

    Pass equality function constructed from trie comparison function to tNFA 
functions
---
 trie.el | 17 +++++++++++++++--
 1 file changed, 15 insertions(+), 2 deletions(-)

diff --git a/trie.el b/trie.el
index 630a40f..05c462c 100644
--- a/trie.el
+++ b/trie.el
@@ -293,6 +293,14 @@
           (t (,cmpfun a b)))))
 
 
+(defun trie--construct-equality-function (comparison-function)
+  ;; create equality function from trie comparison function
+  `(lambda (a b)
+     (and (not (,comparison-function a b))
+         (not (,comparison-function b a)))))
+
+
+
 ;;; ----------------------------------------------------------------
 ;;;          Functions and macros for handling a trie node.
 
@@ -1589,7 +1597,8 @@ default key-data cons cell."
    rankfun maxnum reverse filter resultfun accumulator nil
    (trie--do-regexp-search
     (trie--root trie)
-    (tNFA-from-regexp regexp)
+    (tNFA-from-regexp regexp :test (trie--construct-equality-function
+                                   (trie--comparison-function trie)))
     (cond ((stringp regexp) "") ((listp regexp) ()) (t []))
     0 (or (and maxnum reverse) (and (not maxnum) (not reverse)))
     (trie--comparison-function trie)
@@ -1695,7 +1704,11 @@ elements that matched the corresponding groups, in 
order."
   ;; Construct store for regexp stack based on TRIE.
   (let ((seq (cond ((stringp regexp) "") ((listp regexp) ()) (t [])))
        store)
-    (push (list seq (trie--root trie) (tNFA-from-regexp regexp) 0)
+    (push (list seq (trie--root trie)
+               (tNFA-from-regexp
+                regexp :test (trie--construct-equality-function
+                              (trie--comparison-function trie)))
+               0)
          store)
     (trie--regexp-stack-repopulate
      store reverse



reply via email to

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