]> gitweb.factorcode.org Git - factor.git/commitdiff
linked-assocs: rollback to old clone method.
authorJohn Benediktsson <mrjbq7@gmail.com>
Fri, 19 Mar 2021 03:41:03 +0000 (20:41 -0700)
committerJohn Benediktsson <mrjbq7@gmail.com>
Fri, 19 Mar 2021 03:41:03 +0000 (20:41 -0700)
basis/linked-assocs/linked-assocs.factor
extra/lru-cache/lru-cache.factor

index 2b811c08ea2feece8c1933cacddc044cd97664a8..a341ecc5726b2d1d0cfdbd68f2d1b94e526169d5 100644 (file)
@@ -4,8 +4,6 @@ USING: accessors arrays assocs classes deques dlists fry
 hashtables kernel parser sequences.private vocabs.loader ;
 IN: linked-assocs
 
-SLOT: dlist ! FIXME: needed for change-dlist for some reason
-
 TUPLE: linked-assoc { assoc read-only } { dlist dlist read-only } ;
 
 : <linked-assoc> ( exemplar -- assoc )
@@ -48,7 +46,7 @@ M: linked-assoc clear-assoc
     [ assoc>> clear-assoc ] [ dlist>> clear-deque ] bi ;
 
 M: linked-assoc clone
-    (clone) [ clone ] change-assoc [ clone ] change-dlist ;
+    [ assoc>> clone ] [ dlist>> clone ] bi linked-assoc boa ;
 
 INSTANCE: linked-assoc assoc
 
index 5fed8f33f1b6a162cd43cfaeb18e82e742b62e5d..af297c4e8645b76625b2c670035c7124f7d02729 100644 (file)
@@ -32,6 +32,10 @@ M: lru-cache set-at
         ] [ drop ] if
     ] [ drop ] if* ;
 
+M: lru-cache clone
+    [ assoc>> clone ] [ dlist>> clone ] [ max-size>> ] tri
+    lru-cache boa ;
+
 TUPLE: fifo-cache < linked-assoc max-size ;
 
 : <fifo-cache> ( max-size exemplar -- assoc )
@@ -49,6 +53,10 @@ M: fifo-cache set-at
         ] [ drop ] if
     ] [ drop ] if* ;
 
+M: fifo-cache clone
+    [ assoc>> clone ] [ dlist>> clone ] [ max-size>> ] tri
+    fifo-cache boa ;
+
 TUPLE: lifo-cache < linked-assoc max-size ;
 
 : <lifo-cache> ( max-size exemplar -- assoc )
@@ -66,3 +74,7 @@ M: lifo-cache set-at
             [ dlist>> ] tri (delete-at)
         ] when
     ] when* call-next-method ;
+
+M: lifo-cache clone
+    [ assoc>> clone ] [ dlist>> clone ] [ max-size>> ] tri
+    lifo-cache boa ;