branch: elpa/gptel
commit 13baa6754e7b12ce9f0a5a87bf11cf01d1b753d8
Author: Karthik Chikmagalur <[email protected]>
Commit: Karthik Chikmagalur <[email protected]>

    gptel-request: Speed up temp file creation
    
    * gptel-request.el (gptel-curl--get-args): When the payload is too
    large, we write request data to a temporary JSON file.  (This is
    controlled by `gptel-curl-file-size-threshold'.)
    
    Try to speed up this write operation with the usual tricks.
    Inhibiting fsync is irrelevant for tmpfs but there is no guarantee
    that the temp file will be created in memory on all systems.
---
 gptel-request.el | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/gptel-request.el b/gptel-request.el
index 95bab552c7f..701c8df6b9c 100644
--- a/gptel-request.el
+++ b/gptel-request.el
@@ -2529,7 +2529,9 @@ INFO contains the request data, TOKEN is a unique 
identifier."
      (if (length< data-json gptel-curl-file-size-threshold)
          (list (format "-d%s" data-json))
        (letrec
-           ((temp-filename (make-temp-file "gptel-curl-data" nil ".json" 
data-json))
+           ((write-region-inhibit-fsync t)
+            (file-name-handler-alist nil)
+            (temp-filename (make-temp-file "gptel-curl-data" nil ".json" 
data-json))
             (cleanup-fn (lambda (&rest _)
                           (when (file-exists-p temp-filename)
                             (delete-file temp-filename)

Reply via email to