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

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

[elpa] externals/xelb df102a5: Speed up large string to by conversions


From: Chris Feng
Subject: [elpa] externals/xelb df102a5: Speed up large string to by conversions
Date: Sun, 19 Jul 2020 09:56:34 -0400 (EDT)

branch: externals/xelb
commit df102a5773b37cec154e795a17a8513144dde643
Author: Lars Ingebrigtsen <larsi@gnus.org>
Commit: Chris Feng <chris.w.feng@gmail.com>

    Speed up large string to by conversions
    
    When using xcb:PutImage objects, the data fields can be huge.  These
    are (commonly) strings that are to be converted to byte arrays, so
    there's no need to call xcb:-marshal-field on every character.
---
 xcb-types.el | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/xcb-types.el b/xcb-types.el
index c9f60f1..a9399ae 100644
--- a/xcb-types.el
+++ b/xcb-types.el
@@ -545,7 +545,14 @@ The optional POS argument indicates current byte index of 
the field (used by
          (unless list-size
            (setq list-size (length data)))) ;list-size can be nil
        (cl-assert (= list-size (length data)))
-       (mapconcat (lambda (i) (xcb:-marshal-field obj list-type i)) data [])))
+       ;; The data may be large, and if it's a string that's supposed
+       ;; to be converted to a vector of bytes, then the transform can
+       ;; be done trivially and much faster by just coercing.
+       (if (and (eq list-type 'xcb:BYTE)
+               (eq (type-of data) 'string))
+          (cl-coerce data 'vector)
+        (mapconcat (lambda (i) (xcb:-marshal-field obj list-type i))
+                   data []))))
     (`xcb:-switch
      (let ((slots (eieio-class-slots (eieio-object-class obj)))
            (expression (plist-get value 'expression))



reply via email to

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