[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/ebdb a43e883 026/350: Move record initialization out of
From: |
Eric Abrahamsen |
Subject: |
[elpa] externals/ebdb a43e883 026/350: Move record initialization out of load process |
Date: |
Mon, 14 Aug 2017 11:45:56 -0400 (EDT) |
branch: externals/ebdb
commit a43e883eaa3f8c5360394952717ef2c598bf99cf
Author: Eric Abrahamsen <address@hidden>
Commit: Eric Abrahamsen <address@hidden>
Move record initialization out of load process
Part of the motivation of this is that initialization creates
connections between records. If those records are living in separate
databases, then all databases need to be loaded before initialization
happens.
* ebdb.el (ebdb-db-load): Don't initialize records here.
(ebdb-initialize): Instead, create a separate function for doing
that.
(ebdb-load): And call it here, after all databases are loaded.
---
ebdb.el | 40 +++++++++++++++++++---------------------
1 file changed, 19 insertions(+), 21 deletions(-)
diff --git a/ebdb.el b/ebdb.el
index 94a753a..5387ec8 100644
--- a/ebdb.el
+++ b/ebdb.el
@@ -1736,17 +1736,12 @@ from its respective databases, un-hashing its uuid,
running
(cl-call-next-method record slots))))
(cl-defmethod ebdb-init ((record ebdb-record))
- "Initiate a record after loading a database or creating a new record.
-
-Call `ebdb-init' on all of a record's user fields."
+ "Initiate a record after loading a database or creating a new
+record."
(dolist (field (ebdb-record-user-fields record))
(ebdb-init field record))
(let ((uuid (ebdb-record-uuid record)))
- (ebdb-puthash uuid record)
- ;; I don't think there are any cases when we would be at this
- ;; point in the code and the uuid would already be seen, but...
- (unless (member uuid ebdb-seen-uuids)
- (push uuid ebdb-seen-uuids)))
+ (ebdb-puthash uuid record))
(ebdb-record-set-sortkey record))
(cl-defmethod ebdb-merge ((left ebdb-record)
@@ -2781,17 +2776,12 @@ overwrite data somewhere."
;; Cycle over each loaded record.
(condition-case err
(progn
- ;; First, tell it about the database.
+ ;; Tell it about the database.
(object-add-to-list (ebdb-record-cache rec)
'database db)
- ;; Make sure its UUID is unique.
- (ebdb-check-uuid (ebdb-record-uuid rec))
-
- ;; Lastly initialize it. This has to come after
- ;; `ebdb-check-uuid' because it adds the record's UUID to
- ;; `ebdb-seen-uuids'.
- (ebdb-init rec))
+ ;; Make sure its UUID is unique. Doesn't create new UUIDs.
+ (ebdb-check-uuid (ebdb-record-uuid rec)))
(ebdb-duplicate-uuid
;; There's a duplicate, decide what to do about it. In the
@@ -2837,11 +2827,7 @@ overwrite data somewhere."
(object-add-to-list db 'records keeper)
(object-add-to-list (ebdb-record-cache keeper)
'database d))
- (ebdb-delete deleter)
- ;; Double was initialized, rec wasn't. If we end up keeping
- ;; rec, we need to initialize it.
- (when delete-double
- (ebdb-init keeper)))))))
+ (ebdb-delete deleter))))))
(cl-defmethod ebdb-db-unload ((db ebdb-db))
"Unload database DB.
@@ -4320,11 +4306,23 @@ important work is done by the `ebdb-db-load' method."
;; We're migrating from a previous version of EBDB.
(ebdb-migrate-from-bbdb)
(message "Loading EBDB sources... done"))
+ (ebdb-initialize)
;; Users will expect the same ordering as `ebdb-sources'
(setq ebdb-db-list (nreverse ebdb-db-list))
(run-hooks 'ebdb-after-load-hook)
(length ebdb-record-tracker)))
+;; If we wanted to make it seem like EBDB was loading faster, we could
+;; defer calls to `ebdb-initialize' until the first time the database
+;; is searched.
+(defun ebdb-initialize ()
+ "After all databases are loaded, initialize the records.
+
+This results in the creation of all the secondary data
+structures: label lists, `ebdb-org-hashtable', record caches,
+etc."
+ (mapcar #'ebdb-init ebdb-record-tracker))
+
(defun ebdb-address-continental-p (address)
"Return non-nil if ADDRESS is a continental address.
This is done by comparing the postcode to `ebdb-continental-postcode-regexp'.
- [elpa] externals/ebdb 2ec61be 059/350: Fixup bbdb-mode keymap, menu, and docstring, (continued)
- [elpa] externals/ebdb 2ec61be 059/350: Fixup bbdb-mode keymap, menu, and docstring, Eric Abrahamsen, 2017/08/14
- [elpa] externals/ebdb e49e9da 077/350: Using wrong var name in ebdb-edit-field, Eric Abrahamsen, 2017/08/14
- [elpa] externals/ebdb 794babc 069/350: Fix mail field action, Eric Abrahamsen, 2017/08/14
- [elpa] externals/ebdb 7d41fb9 076/350: Small tweaks to ebdb-load, Eric Abrahamsen, 2017/08/14
- [elpa] externals/ebdb 5156eb2 079/350: Rename ebdb-display-one-record to ebdb-search-single-record, Eric Abrahamsen, 2017/08/14
- [elpa] externals/ebdb 3a0048f 041/350: Stop pretended init and delete are the same for records and fields, Eric Abrahamsen, 2017/08/14
- [elpa] externals/ebdb ca4516b 082/350: Use mail-decode-encoded-word-string on returned MUA headers, Eric Abrahamsen, 2017/08/14
- [elpa] externals/ebdb 5910db7 065/350: Restore mail alias functionality, Eric Abrahamsen, 2017/08/14
- [elpa] externals/ebdb 55a8c97 085/350: Split ebdb-db-disable into interactive/non-interactive functions, Eric Abrahamsen, 2017/08/14
- [elpa] externals/ebdb fb76dd3 032/350: Fix ebdb-search-duplicates, Eric Abrahamsen, 2017/08/14
- [elpa] externals/ebdb a43e883 026/350: Move record initialization out of load process,
Eric Abrahamsen <=
- [elpa] externals/ebdb 77eb15b 037/350: Add keybinding for ebdb-search-database, Eric Abrahamsen, 2017/08/14
- [elpa] externals/ebdb 8eb2262 036/350: Add object-print method for records, Eric Abrahamsen, 2017/08/14
- [elpa] externals/ebdb 20785a1 029/350: Additions to README and manual, Eric Abrahamsen, 2017/08/14
- [elpa] externals/ebdb 8537076 052/350: Improvements to the gnorb-ebdb-org-tags field, Eric Abrahamsen, 2017/08/14
- [elpa] externals/ebdb 6568bbf 053/350: Straighten out ebdb-separator-alist, Eric Abrahamsen, 2017/08/14
- [elpa] externals/ebdb 9791ed5 030/350: Merge branch 'buff', Eric Abrahamsen, 2017/08/14
- [elpa] externals/ebdb 49b422e 035/350: Remove mentions and bindings for ebdb-do-all-records, Eric Abrahamsen, 2017/08/14
- [elpa] externals/ebdb 11fe701 047/350: Name classes now inherit from ebdb-field-user, Eric Abrahamsen, 2017/08/14
- [elpa] externals/ebdb 784f45c 060/350: New function ebdb-prompt-for-mail, Eric Abrahamsen, 2017/08/14
- [elpa] externals/ebdb a712f52 050/350: Update ebdb-pgp, Eric Abrahamsen, 2017/08/14