[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/ebdb 7126d5d 027/350: Hash record uuids during the load
From: |
Eric Abrahamsen |
Subject: |
[elpa] externals/ebdb 7126d5d 027/350: Hash record uuids during the loading process |
Date: |
Mon, 14 Aug 2017 11:45:56 -0400 (EDT) |
branch: externals/ebdb
commit 7126d5db41f4b09dc5ebac27ea91e94866801284
Author: Eric Abrahamsen <address@hidden>
Commit: Eric Abrahamsen <address@hidden>
Hash record uuids during the loading process
As each record is loaded, hash its uuid. This allows the use of
`ebdb-gethash' uuid lookups later, during the initialization process.
* ebdb.el (ebdb-init): Do not hash the uuid during record init.
(ebdb-db-load): Instead, hash during record load.
(ebdb-check-uuid): Now we can use `ebdb-gethash' in this function.
(ebdb-record-insert-field): And in the loading of role fields.
---
ebdb.el | 29 +++++++++--------------------
1 file changed, 9 insertions(+), 20 deletions(-)
diff --git a/ebdb.el b/ebdb.el
index 5387ec8..eac7492 100644
--- a/ebdb.el
+++ b/ebdb.el
@@ -923,11 +923,7 @@ process."
(cl-defmethod ebdb-init ((role ebdb-field-role) &optional record)
(when record
(let* ((org-uuid (slot-value role 'org-uuid))
- (org (seq-find ;; TODO: This is very slow.
- (lambda (r)
- (equal org-uuid (ebdb-record-uuid r)))
- ebdb-record-tracker))
- (org-string (ebdb-string (slot-value org 'name)))
+ (org (ebdb-gethash org-uuid 'uuid))
;; TODO: Guard against org-entry not being found.
(org-entry (gethash org-uuid ebdb-org-hashtable))
(record-uuid (ebdb-record-uuid record))
@@ -943,7 +939,7 @@ process."
(object-add-to-list (ebdb-record-cache record) 'organizations org-string)
;; Init the role mail against the record.
(when (and role-mail (slot-value role-mail 'mail))
- (ebdb-init role-mail record))
+ (ebdb-init role-mail record))
;; Make sure this role is in the `ebdb-org-hashtable'.
(unless (and org-entry
(dolist (pair org-entry exists-p)
@@ -966,9 +962,6 @@ process."
(let* ((org-uuid (slot-value role 'org-uuid))
(org-string
(slot-value
- ;; `ebdb-init' can't use `ebdb-gethash' for this, because
- ;; not all the records will be hashed during the loading
- ;; process. We should be safe to use it here, though.
(ebdb-gethash org-uuid 'uuid)
'name))
(org-entry (gethash org-uuid ebdb-org-hashtable))
@@ -1740,8 +1733,6 @@ from its respective databases, un-hashing its uuid,
running
record."
(dolist (field (ebdb-record-user-fields record))
(ebdb-init field record))
- (let ((uuid (ebdb-record-uuid record)))
- (ebdb-puthash uuid record))
(ebdb-record-set-sortkey record))
(cl-defmethod ebdb-merge ((left ebdb-record)
@@ -2500,10 +2491,7 @@ appropriate person record."
_slot
(field ebdb-field-role))
(let* ((org-uuid (slot-value field 'org-uuid))
- (org (seq-find
- (lambda (r)
- (equal org-uuid (ebdb-record-uuid r)))
- ebdb-record-tracker))
+ (org (ebdb-gethash org-uuid 'uuid))
(org-domain (slot-value org 'domain))
(role-mail (slot-value field 'mail)))
(when (and org-domain (not role-mail))
@@ -2570,10 +2558,7 @@ instances to add as part of the role."
error containing the record that already has that uuid."
(when (member uuid ebdb-seen-uuids)
(signal 'ebdb-duplicate-uuid
- (list (seq-find
- (lambda (r)
- (equal uuid (ebdb-record-uuid r)))
- ebdb-record-tracker)))))
+ (list (ebdb-gethash uuid 'uuid)))))
(defun ebdb-make-uuid (&optional prefix)
"Create and return a new UUID.
@@ -2781,7 +2766,11 @@ overwrite data somewhere."
'database db)
;; Make sure its UUID is unique. Doesn't create new UUIDs.
- (ebdb-check-uuid (ebdb-record-uuid rec)))
+ (ebdb-check-uuid (ebdb-record-uuid rec))
+
+ ;; Hash the record against its UUID. This provides some
+ ;; speedup in the later initialization process.
+ (ebdb-puthash (ebdb-record-uuid rec) rec))
(ebdb-duplicate-uuid
;; There's a duplicate, decide what to do about it. In the
- [elpa] externals/ebdb 1ee7829 012/350: Don't auto-save unsynced databases, (continued)
- [elpa] externals/ebdb 1ee7829 012/350: Don't auto-save unsynced databases, Eric Abrahamsen, 2017/08/14
- [elpa] externals/ebdb ac0b822 010/350: Switch to using kbd macro in keymap def, Eric Abrahamsen, 2017/08/14
- [elpa] externals/ebdb 9edb0c0 015/350: Sort out catch-all version of ebdb-make-buffer-name, Eric Abrahamsen, 2017/08/14
- [elpa] externals/ebdb 74ed051 009/350: Better customization setup for record fields, Eric Abrahamsen, 2017/08/14
- [elpa] externals/ebdb c803f1c 004/350: Forgot extra argument to ebdb-delete-i18n, Eric Abrahamsen, 2017/08/14
- [elpa] externals/ebdb 22734d1 019/350: Select newly-cloned buffers, Eric Abrahamsen, 2017/08/14
- [elpa] externals/ebdb 94c7c6b 039/350: Provide ebdb-load guards in a few more places, Eric Abrahamsen, 2017/08/14
- [elpa] externals/ebdb 015bd25 038/350: New search command ebdb-search-record-class, Eric Abrahamsen, 2017/08/14
- [elpa] externals/ebdb f288cba 034/350: Use "d" prefix for record/database move commands, Eric Abrahamsen, 2017/08/14
- [elpa] externals/ebdb 7721bf3 044/350: Mess with autoloads, Eric Abrahamsen, 2017/08/14
- [elpa] externals/ebdb 7126d5d 027/350: Hash record uuids during the loading process,
Eric Abrahamsen <=
- [elpa] externals/ebdb 60aea3d 045/350: ebdb-create-record: set record class outside of interactive call, Eric Abrahamsen, 2017/08/14
- [elpa] externals/ebdb e178321 051/350: Trailing code in last commit, Eric Abrahamsen, 2017/08/14
- [elpa] externals/ebdb c212316 014/350: First commit of buffer improvements, Eric Abrahamsen, 2017/08/14
- [elpa] externals/ebdb dbd3559 042/350: Do away with ebdb-seen-uuids, Eric Abrahamsen, 2017/08/14
- [elpa] externals/ebdb 7570ed9 040/350: Protect against non-present records in role delete method, Eric Abrahamsen, 2017/08/14
- [elpa] externals/ebdb c44b910 056/350: New ebdb-copy-mail-as-kill command, Eric Abrahamsen, 2017/08/14
- [elpa] externals/ebdb 10b0fa4 057/350: Use save-excursion in ebdb-toggle-all-record-marks, Eric Abrahamsen, 2017/08/14
- [elpa] externals/ebdb a2d2116 058/350: Use eieio-object-p instead of vectorp, Eric Abrahamsen, 2017/08/14
- [elpa] externals/ebdb a158434 055/350: Remove ebdb-browse-url, Eric Abrahamsen, 2017/08/14
- [elpa] externals/ebdb e50a437 043/350: When unloading, don't remove records from the db's record slot, Eric Abrahamsen, 2017/08/14