mirror of
https://codeberg.org/cage/tinmop/
synced 2025-02-17 08:10:36 +01:00
- using a cache for username completion.
This commit is contained in:
parent
aa24c49753
commit
9876213933
@ -137,7 +137,26 @@ list af all possible candidtae for completion."
|
||||
|
||||
(with-simple-complete ignored-username-complete db:all-ignored-usernames)
|
||||
|
||||
(with-simple-complete username-complete db:all-usernames)
|
||||
(let ((memoized (make-hash-table :test #'equalp)))
|
||||
|
||||
(defun set-username-cache-value (hint)
|
||||
(setf (gethash hint memoized)
|
||||
(remove-if-not (starts-with-clsr hint)
|
||||
(db:all-usernames))))
|
||||
|
||||
(defun initialize-complete-username-cache ()
|
||||
(set-username-cache-value "")
|
||||
(loop for i in (coerce "abcdefghijklmnopqrstuvwuxyz" 'list) do
|
||||
(set-username-cache-value (string i))))
|
||||
|
||||
(defun username-complete (hint)
|
||||
(multiple-value-bind (matched found)
|
||||
(gethash hint memoized)
|
||||
(if (null found)
|
||||
(progn
|
||||
(set-username-cache-value hint)
|
||||
(username-complete hint))
|
||||
(values matched (reduce-to-common-prefix matched))))))
|
||||
|
||||
(with-simple-complete visibility-complete (lambda () swconf:*allowed-status-visibility*))
|
||||
|
||||
|
@ -1031,6 +1031,7 @@ than (swconf:config-purge-history-days-offset) days in the past"
|
||||
(actual-moved-id (if moved
|
||||
(prepare-for-db (tooter:id moved))
|
||||
(prepare-for-db nil))))
|
||||
(complete:initialize-complete-username-cache)
|
||||
(insert-or-update +table-account+
|
||||
(:id
|
||||
:username
|
||||
|
@ -110,6 +110,7 @@ etc.) happened"
|
||||
(init-db)
|
||||
(gemini-client:init-default-gemini-theme)
|
||||
(db-utils:with-ready-database (:connect nil)
|
||||
(complete:initialize-complete-username-cache)
|
||||
(modules:load-module +starting-init-file+)
|
||||
;; init main window for first...
|
||||
(main-window:init)
|
||||
|
@ -1211,6 +1211,7 @@
|
||||
:folder-complete
|
||||
:timeline-complete-fn
|
||||
:ignored-username-complete
|
||||
:initialize-complete-username-cache
|
||||
:username-complete
|
||||
:visibility-complete
|
||||
:unfollowed-user-complete
|
||||
|
Loading…
x
Reference in New Issue
Block a user