mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-04-30 03:40:34 +02:00
Use transient intset/intmap optimizations when computing SCCs
* module/language/cps/graphs.scm (compute-sorted-strongly-connected-components): Use more transient data structures.
This commit is contained in:
parent
60c1e5cc42
commit
47dce42edb
1 changed files with 16 additions and 14 deletions
|
@ -1,6 +1,6 @@
|
||||||
;;; Continuation-passing style (CPS) intermediate language (IL)
|
;;; 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
|
;;;; This library is free software; you can redistribute it and/or
|
||||||
;;;; modify it under the terms of the GNU Lesser General Public
|
;;;; modify it under the terms of the GNU Lesser General Public
|
||||||
|
@ -227,23 +227,25 @@ connected components in sorted order."
|
||||||
start)
|
start)
|
||||||
start))
|
start))
|
||||||
(define node-components
|
(define node-components
|
||||||
(intmap-fold (lambda (id nodes out)
|
(persistent-intmap
|
||||||
(intset-fold (lambda (node out) (intmap-add out node id))
|
(intmap-fold (lambda (id nodes out)
|
||||||
nodes out))
|
(intset-fold (lambda (node out) (intmap-add! out node id))
|
||||||
components
|
nodes out))
|
||||||
empty-intmap))
|
components
|
||||||
|
empty-intmap)))
|
||||||
(define (node-component node)
|
(define (node-component node)
|
||||||
(intmap-ref node-components node))
|
(intmap-ref node-components node))
|
||||||
(define (component-successors id nodes)
|
(define (component-successors id nodes)
|
||||||
(intset-remove
|
(intset-remove
|
||||||
(intset-fold (lambda (node out)
|
(persistent-intset
|
||||||
(intset-fold
|
(intset-fold (lambda (node out)
|
||||||
(lambda (successor out)
|
(intset-fold
|
||||||
(intset-add out (node-component successor)))
|
(lambda (successor out)
|
||||||
(intmap-ref edges node)
|
(intset-add! out (node-component successor)))
|
||||||
out))
|
(intmap-ref edges node)
|
||||||
nodes
|
out))
|
||||||
empty-intset)
|
nodes
|
||||||
|
empty-intset))
|
||||||
id))
|
id))
|
||||||
(define component-edges
|
(define component-edges
|
||||||
(intmap-map component-successors components))
|
(intmap-map component-successors components))
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue