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

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

[elpa] externals/xelb 15f4884455: Use an offset argument to improve perf


From: ELPA Syncer
Subject: [elpa] externals/xelb 15f4884455: Use an offset argument to improve performance during unmarshalling (#7)
Date: Mon, 22 Jan 2024 03:59:29 -0500 (EST)

branch: externals/xelb
commit 15f48844557f47df3d86814c7c35b47b69eeb861
Author: Steven Allen <steven@stebalien.com>
Commit: GitHub <noreply@github.com>

    Use an offset argument to improve performance during unmarshalling (#7)
    
    This builds upon ch11ng/xelb#2 which did most of the work. For some reason 
the
    original PR did hardcode the offset to 0 and instead created copies of the 
array
    with an increasing offset instead.
    
    * xcb-types.el: (xcb:unmarshal, xcb:-unmarshal-field): Use offsets instead 
of
      allocating substrings of the data.
    
    Co-authored-by: Vasilij Schneidermann <mail@vasilij.de>
    Co-authored-by: Daniel Mendler <mail@daniel-mendler.de>
---
 xcb-types.el | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/xcb-types.el b/xcb-types.el
index 42ae7d1d7b..af7aa6da84 100644
--- a/xcb-types.el
+++ b/xcb-types.el
@@ -633,11 +633,10 @@ The optional argument CTX is for <paramref>."
         (setq type (cl--slot-descriptor-type slot))
         (unless (eq type 'xcb:-ignore)
           (setq slot-name (eieio-slot-descriptor-name slot)
-                tmp (xcb:-unmarshal-field obj type byte-array 0
+                tmp (xcb:-unmarshal-field obj type byte-array result
                                           (eieio-oref-default obj slot-name)
                                           ctx total-length))
           (setf (slot-value obj slot-name) (car tmp))
-          (setq byte-array (substring byte-array (cadr tmp)))
           (setq result (+ result (cadr tmp)))
           (when (eq type 'xcb:-switch) ;xcb:-switch always finishes a struct
             (throw 'break 'nil)))))
@@ -778,12 +777,11 @@ and the second the consumed length."
                    (setq slot-type (cl--slot-descriptor-type slot))
                    (throw 'break nil))))
              (unless (eq slot-type 'xcb:-ignore)
-               (setq tmp (xcb:-unmarshal-field obj slot-type data offset
+               (setq tmp (xcb:-unmarshal-field obj slot-type data (+ offset 
count)
                                                (eieio-oref-default obj name)
                                                nil total-length))
                (setf (slot-value obj name) (car tmp))
-               (setq count (+ count (cadr tmp)))
-               (setq data (substring data (cadr tmp)))))))
+               (setq count (+ count (cadr tmp)))))))
        (list initform count)))
     ((and x (guard (child-of-class-p x 'xcb:-struct)))
      (let* ((struct-obj (make-instance x))



reply via email to

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