From: plugd Date: Sat, 31 Jul 2021 11:44:12 +0000 (+0200) Subject: Merge branch 'master' into about-pages X-Git-Tag: v3.2.0~9 X-Git-Url: https://thelambdalab.xyz/gitweb/index.cgi?p=elpher.git;a=commitdiff_plain;h=befa575d2a89dbee6c30443cced03b0ef89977b4;hp=34427dedd5270a954966fff20ac523131661e5c7 Merge branch 'master' into about-pages --- diff --git a/ISSUES.org b/ISSUES.org index cf082d1..9923820 100644 --- a/ISSUES.org +++ b/ISSUES.org @@ -260,3 +260,20 @@ collapsable hierarchies. :LOGBOOK: - State "CLOSED" from "OPEN" [2021-07-23 Fri 10:09] :END: + +** CLOSED Improve gemeini rendering speed +:LOGBOOK: +- State "CLOSED" from "OPEN" [2021-07-31 Sat 00:18] +:END: + +Currently pages with many links render extremely slowly. + +Example (>2000 links, 15s): gemini://rawtext.club/~sloum/geminilist/ + +It turns out that by far the main contributor to this is the use of +(url-port) in elpher-address-from-gemini-url. I encountered this +problem once before in elpher-remove-redundant-ports. This function +call is just incredibly slow for some bizarre reason. Happily, +(url-portspec) is functionally equivalent and is orders of magnitude +faster. With this replacement, loading the above page takes ~2s +and there aren't any other hotspots. diff --git a/elpher.el b/elpher.el index 7c68b5c..651318d 100644 --- a/elpher.el +++ b/elpher.el @@ -129,6 +129,7 @@ (defvar ansi-color-context) (defvar bookmark-make-record-function) (defvar mu4e~view-beginning-of-url-regexp) + (defvar eww-use-browse-url) (defvar thing-at-point-uri-schemes) (defvar xterm-color-preserve-properties)) @@ -1453,7 +1454,7 @@ treatment that a separate function is warranted." (if (string-empty-p (url-filename address)) (setf (url-filename address) "/")) ;ensure empty filename is marked as absolute (setf (url-host address) (url-host current-address)) - (setf (url-port address) (url-port current-address)) + (setf (url-portspec address) (url-portspec current-address)) ; (url-port) too slow! (unless (string-prefix-p "/" (url-filename address)) ;deal with relative links (setf (url-filename address) (concat (file-name-directory (url-filename current-address)) @@ -2079,21 +2080,23 @@ supports the old protocol elpher, where the link is self-contained." "Go to a particular gopher site HOST-OR-URL. When run interactively HOST-OR-URL is read from the minibuffer." (interactive "sGopher or Gemini URL: ") - (let* ((cleaned-host-or-url (string-trim host-or-url)) - (address (elpher-address-from-url cleaned-host-or-url)) - (page (elpher-make-page cleaned-host-or-url address))) - (switch-to-buffer elpher-buffer-name) - (elpher-with-clean-buffer - (elpher-visit-page page)) - nil)) + (let ((trimmed-host-or-url (string-trim host-or-url))) + (unless (string-empty-p trimmed-host-or-url) + (let* ((address (elpher-address-from-url trimmed-host-or-url)) + (page (elpher-make-page trimmed-host-or-url address))) + (switch-to-buffer elpher-buffer-name) + (elpher-with-clean-buffer + (elpher-visit-page page)) + nil)))) ; non-nil value is displayed by eshell (defun elpher-go-current () "Go to a particular site read from the minibuffer, initialized with the current URL." (interactive) - (let ((address (elpher-page-address elpher-current-page))) - (let ((url (read-string "Gopher or Gemini URL: " - (unless (elpher-address-special-p address) - (elpher-address-to-url address))))) + (let* ((address (elpher-page-address elpher-current-page)) + (url (read-string "Gopher or Gemini URL: " + (unless (elpher-address-special-p address) + (elpher-address-to-url address))))) + (unless (string-empty-p (string-trim url)) (elpher-visit-page (elpher-make-page url (elpher-address-from-url url)))))) (defun elpher-redraw ()