guile-commits
[Top][All Lists]
Advanced

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

[Guile-commits] 03/04: Use transient intset/intmap optimizations when co


From: Andy Wingo
Subject: [Guile-commits] 03/04: Use transient intset/intmap optimizations when computing SCCs
Date: Wed, 22 Jan 2025 11:12:41 -0500 (EST)

wingo pushed a commit to branch main
in repository guile.

commit 47dce42edb3d158d6a71eb4da8421287b88c9ef1
Author: Andy Wingo <wingo@pobox.com>
AuthorDate: Wed Jan 22 16:50:52 2025 +0100

    Use transient intset/intmap optimizations when computing SCCs
    
    * module/language/cps/graphs.scm 
(compute-sorted-strongly-connected-components):
    Use more transient data structures.
---
 module/language/cps/graphs.scm | 30 ++++++++++++++++--------------
 1 file changed, 16 insertions(+), 14 deletions(-)

diff --git a/module/language/cps/graphs.scm b/module/language/cps/graphs.scm
index a518afc55..78e4ef070 100644
--- a/module/language/cps/graphs.scm
+++ b/module/language/cps/graphs.scm
@@ -1,6 +1,6 @@
 ;;; Continuation-passing style (CPS) intermediate language (IL)
 
-;; Copyright (C) 2013-2015, 2017-2021 Free Software Foundation, Inc.
+;; Copyright (C) 2013-2015, 2017-2021, 2025 Free Software Foundation, Inc.
 
 ;;;; This library is free software; you can redistribute it and/or
 ;;;; modify it under the terms of the GNU Lesser General Public
@@ -227,23 +227,25 @@ connected components in sorted order."
                                             start)
      start))
   (define node-components
-    (intmap-fold (lambda (id nodes out)
-                   (intset-fold (lambda (node out) (intmap-add out node id))
-                                nodes out))
-                 components
-                 empty-intmap))
+    (persistent-intmap
+     (intmap-fold (lambda (id nodes out)
+                    (intset-fold (lambda (node out) (intmap-add! out node id))
+                                 nodes out))
+                  components
+                  empty-intmap)))
   (define (node-component node)
     (intmap-ref node-components node))
   (define (component-successors id nodes)
     (intset-remove
-     (intset-fold (lambda (node out)
-                    (intset-fold
-                     (lambda (successor out)
-                       (intset-add out (node-component successor)))
-                     (intmap-ref edges node)
-                     out))
-                  nodes
-                  empty-intset)
+     (persistent-intset
+      (intset-fold (lambda (node out)
+                     (intset-fold
+                      (lambda (successor out)
+                        (intset-add! out (node-component successor)))
+                      (intmap-ref edges node)
+                      out))
+                   nodes
+                   empty-intset))
      id))
   (define component-edges
     (intmap-map component-successors components))



reply via email to

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