emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] externals/emacs-gc-stats 048af820a7 06/24: emacs-gc-stats-save-se


From: ELPA Syncer
Subject: [elpa] externals/emacs-gc-stats 048af820a7 06/24: emacs-gc-stats-save-session: Smarter repeated session data save
Date: Sat, 10 Jun 2023 12:58:44 -0400 (EDT)

branch: externals/emacs-gc-stats
commit 048af820a7f08fe59ca84e6e78c8a254613ab3ec
Author: Ihor Radchenko <yantar92@posteo.net>
Commit: Ihor Radchenko <yantar92@posteo.net>

    emacs-gc-stats-save-session: Smarter repeated session data save
    
    * emacs-gc-stats.el (emacs-gc-stats-save-session): Overwrite
    previously saved data for the current Emacs session.
---
 emacs-gc-stats.el | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/emacs-gc-stats.el b/emacs-gc-stats.el
index e2697f358f..1c2b091749 100644
--- a/emacs-gc-stats.el
+++ b/emacs-gc-stats.el
@@ -131,11 +131,16 @@ Otherwise, collect symbol."
          (and (file-readable-p emacs-gc-stats-file)
               (with-temp-buffer
                 (insert-file-contents emacs-gc-stats-file)
-                (ignore-errors (read (current-buffer)))))))
+                (ignore-errors (read (current-buffer))))))
+        (session (reverse emacs-gc-stats--data)))
+    ;; remove end data in case if we continue recording.
+    (pop emacs-gc-stats--data)
     (with-temp-file emacs-gc-stats-file
       ;; Override partially saved session.
-      (setf (alist-get (car emacs-gc-stats--data) previous-sessions)
-            (cdr emacs-gc-stats--data))
+      (let ((existing (assoc (car session) previous-sessions)))
+        (if existing
+            (setcdr (cdr existing) (cdr session))
+          (push session previous-sessions)))
       (prin1 previous-sessions (current-buffer)))))
 
 (defun emacs-gc-stats-clear ()



reply via email to

[Prev in Thread] Current Thread [Next in Thread]