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

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

[elpa] master ab9b532: Avoid recursive stream-append in stream-concatena


From: Michael Heerdegen
Subject: [elpa] master ab9b532: Avoid recursive stream-append in stream-concatenate
Date: Tue, 2 Aug 2016 00:37:24 +0000 (UTC)

branch: master
commit ab9b532ffa43531dbeea552e81df7fe89aec07e3
Author: Michael Heerdegen <address@hidden>
Commit: Michael Heerdegen <address@hidden>

    Avoid recursive stream-append in stream-concatenate
    
    This fix prevents exceeding `max-lisp-eval-depth' for streams returned
    by stream-concatenate.
---
 packages/stream/stream.el |   14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)

diff --git a/packages/stream/stream.el b/packages/stream/stream.el
index 8b71a1b..853251e 100644
--- a/packages/stream/stream.el
+++ b/packages/stream/stream.el
@@ -4,7 +4,7 @@
 
 ;; Author: Nicolas Petton <address@hidden>
 ;; Keywords: stream, laziness, sequences
-;; Version: 2.2.0
+;; Version: 2.2.1
 ;; Package-Requires: ((emacs "25"))
 ;; Package: stream
 
@@ -377,7 +377,17 @@ will be found by calling FUNCTION on the preceding 
element."
   "Concatenate all streams in STREAM-OF-STREAMS and return the result.
 All elements in STREAM-OF-STREAMS must be streams.  The result is
 a stream."
-  (seq-reduce #'stream-append stream-of-streams (stream-empty)))
+  (stream-make
+   (while (and (not (stream-empty-p stream-of-streams))
+               (stream-empty-p (stream-first stream-of-streams)))
+     (cl-callf stream-rest stream-of-streams))
+   (if (stream-empty-p stream-of-streams)
+       nil
+     (cons
+      (stream-first (stream-first stream-of-streams))
+      (stream-concatenate
+       (stream-cons (stream-rest (stream-first stream-of-streams))
+                    (stream-rest stream-of-streams)))))))
 
 (defun stream-of-directory-files-1 (directory &optional nosort recurse 
follow-links)
   "Helper for `stream-of-directory-files'."



reply via email to

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