From 04594c95ceb8c6818a3f901c636be4dc17a1aff1 Mon Sep 17 00:00:00 2001 From: Tim Vaughan Date: Fri, 15 May 2020 19:12:32 +0200 Subject: [PATCH] Performance optimization for gopher and finger xfers. --- ISSUES.org | 19 ++++++++++++++++++- elpher.el | 18 ++++++++++-------- 2 files changed, 28 insertions(+), 9 deletions(-) diff --git a/ISSUES.org b/ISSUES.org index 5f45081..03ca588 100644 --- a/ISSUES.org +++ b/ISSUES.org @@ -43,9 +43,17 @@ gopher "getter" code differently. ** OPEN Add history browsing + +** OPEN Download/rendering progress feedback + Particularly for large files or complicated pages, elpher can + take a few seconds or more to generate a response. Thhis is + frustrating for users, who are left staring at a blinking + cursor. + A small amount of feedback could help with this. + * Bugs - + * Completed improvements ** CLOSED Turn on lexical scoping @@ -115,6 +123,15 @@ Actually, this command can be useful to correct rendering issues that occasionally pop up in termal windows. Lets leave it for now. ** CLOSED Implement Finger support + +** CLOSED Improve download performance + This is actually easy to fix - the major problem at the moment is + the braindead way the incrementally-retrieved data is recorded: + (setq result-string (concat result-string next-bit)). + This is O(N^2). Yuck! + + Okay, replacing this really does improve things. Large gemini + downloads now seem occur at rates I'd expect. * Closed issues diff --git a/elpher.el b/elpher.el index f1e7fb8..dec79ae 100644 --- a/elpher.el +++ b/elpher.el @@ -506,7 +506,7 @@ to ADDRESS." (let* ((kill-buffer-query-functions nil) (port (elpher-address-port address)) (host (elpher-address-host address)) - (selector-string "") + (selector-string-parts nil) (proc (open-network-stream "elpher-process" nil (if force-ipv4 (dns-query host) host) @@ -538,8 +538,8 @@ to ADDRESS." (set-process-filter proc (lambda (_proc string) (cancel-timer timer) - (setq selector-string - (concat selector-string string)))) + (setq selector-string-parts + (cons string selector-string-parts)))) (set-process-sentinel proc (lambda (_proc event) (condition-case the-error @@ -553,7 +553,8 @@ to ADDRESS." "\r\n")))) (t (cancel-timer timer) - (funcall renderer selector-string) + (funcall renderer (apply #'concat + (reverse selector-string-parts))) (elpher-restore-pos))) (error (elpher-network-error address the-error)))))) @@ -1086,7 +1087,7 @@ For instance, the filename /a/b/../c/./d will reduce to /a/c/d" (port (let ((given-port (elpher-address-port address))) (if (> given-port 0) given-port 79))) (host (elpher-address-host address)) - (selector-string "") + (selector-string-parts nil) (proc (open-network-stream "elpher-process" nil (if force-ipv4 (dns-query host) host) @@ -1107,8 +1108,8 @@ For instance, the filename /a/b/../c/./d will reduce to /a/c/d" (set-process-filter proc (lambda (_proc string) (cancel-timer timer) - (setq selector-string - (concat selector-string string)))) + (setq selector-string-parts + (cons string selector-string-parts)))) (set-process-sentinel proc (lambda (_proc event) (condition-case the-error @@ -1121,7 +1122,8 @@ For instance, the filename /a/b/../c/./d will reduce to /a/c/d" (concat user "\r\n")))) (t (cancel-timer timer) - (funcall renderer selector-string) + (funcall renderer (apply #'concat + (reverse selector-string-parts))) (elpher-restore-pos))))))) (error (elpher-network-error address the-error)))))) -- 2.20.1