From 914d78fefc0e60cadd0857e88951ad17e42ccfb7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hugo=20H=C3=B6rnquist?= Date: Sun, 9 Aug 2020 23:42:03 +0200 Subject: Box approach to partial pages. A partial (currently all) pages gets saved over with sub-streams limited to what was found during our timeframe. Works great for a trailing page, but fails for something which matches nothing (#f). Probably fails for all cases which ends on a page boundry. --- module/srfi/srfi-41/util.scm | 2 +- module/vcomponent/search.scm | 8 ++++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/module/srfi/srfi-41/util.scm b/module/srfi/srfi-41/util.scm index 472170d7..a3f3890b 100644 --- a/module/srfi/srfi-41/util.scm +++ b/module/srfi/srfi-41/util.scm @@ -96,7 +96,7 @@ (if (stream-null? page) stream-null (stream-cons - page + ((@ (srfi srfi-111) box) page) (stream-paginate rest page-size)))))) (define*-public (stream-paginate stream optional: (page-size 10)) diff --git a/module/vcomponent/search.scm b/module/vcomponent/search.scm index 65e2630a..708f0895 100644 --- a/module/vcomponent/search.scm +++ b/module/vcomponent/search.scm @@ -5,6 +5,7 @@ :use-module (srfi srfi-9) :use-module (srfi srfi-41) :use-module (srfi srfi-41 util) + :use-module (srfi srfi-111) ) @@ -52,12 +53,15 @@ ;; stream-force needs to happen within the actual ;; @var{call-with-time-limit}. (lambda () - (let loop ((strm (stream-ref query page))) + (let loop ((strm (unbox (stream-ref query page)))) (if (stream-null? strm) lst (set! lst (cons (stream-car strm) lst)) (loop (stream-cdr strm))))) (lambda _ (format (current-error-port) "~a~%" 'timed-out))) - (reverse lst))) + (let ((list (reverse lst))) + (set-box! (stream-ref query page) + (list->stream list)) + list))) ;; Creates a prepared query wrappend in a paginator. -- cgit v1.2.3