From debbugs-submit-bounces@debbugs.gnu.org Wed Feb 24 20:34:02 2021 Received: (at submit) by debbugs.gnu.org; 25 Feb 2021 01:34:02 +0000 Received: from localhost ([127.0.0.1]:36310 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lF5XU-00056w-J5 for submit@debbugs.gnu.org; Wed, 24 Feb 2021 20:34:02 -0500 Received: from lists.gnu.org ([209.51.188.17]:45530) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lF5XS-00056o-3l for submit@debbugs.gnu.org; Wed, 24 Feb 2021 20:33:59 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:39640) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lF5XR-0005hm-Mt for bug-gnu-emacs@gnu.org; Wed, 24 Feb 2021 20:33:57 -0500 Received: from mail-wr1-x429.google.com ([2a00:1450:4864:20::429]:34828) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lF5XM-0003hy-Fg for bug-gnu-emacs@gnu.org; Wed, 24 Feb 2021 20:33:56 -0500 Received: by mail-wr1-x429.google.com with SMTP id l12so3668104wry.2 for ; Wed, 24 Feb 2021 17:33:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tcd.ie; s=google21; h=from:to:subject:date:message-id:user-agent:mime-version; bh=ov3YT3f/YGAe5bn3IjUwpwsnm+u1TOayuCP1XDl8H3s=; b=EDuyARYjeDPvElzfb4x+9YXjEE7eMN+igidYLRg99H+ZWsE53kFfuw4d/jSIIy4M4x xeg//tH2t2vd8dikO8OByrkzPt/Bv3kwhnITIFpoxwp7ZUmjFwrV3DcLZkKvBtqGXkH2 VFMUq5vuSuth9ODgx/o0Fw4AMh7LsKM6YXN25PKawR+O7vVgWrkCsQ5axacYa2LAPKJw E5c/+WOtEshljcAemlppi7ZTTQT2amwCMEDZzK8OaGkVs7vrq0qhuY5SsUvkQ170oGSp +URbCrP0weHYJM5KsyIgE/CQk3bGtEM/E1w9E3u0ZlDZ86c3J5izjXXYo0onjNI4QmQy 3P8Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:user-agent :mime-version; bh=ov3YT3f/YGAe5bn3IjUwpwsnm+u1TOayuCP1XDl8H3s=; b=W/u3o5g9y5N4o51pkgjzKBX5BqJAsiaBc+kfnDtj/3LWDn/icctonKgYeVr9Trclwt zYy998y2zMSt5p80/9ZpLhZcG+DiAOGbBltDuBxunBPDSSW7C+Fw4C1PdJbKVbDHEd5h NLrf9I1deCLSWU7YIU5IpuF+FlQy567UFWxcCZ5F9Q94bMderTXghBHRF32q3LJpbGbr oagli6uukPsEYgE4HFUjMZQXjt5yPLcynDQ1+B6ECWZKLf2XpxrkMMHF/wnfjRSnIxJb OQLJlZW5ECbCmVDw1TLtom1Qayf6i8MNYIVmGjUGnXE8Db4f2IMrmjPoUydjA9YScDyB Tj5g== X-Gm-Message-State: AOAM5330kH2+QsstCqrLFiKEsdjxM7gm3Sw2iUHWp3V3WRqzUXYR0luf zKO01Cg2GK1mba7GWNwM0G0WU1RmRDiGOw== X-Google-Smtp-Source: ABdhPJzETlEXuDAforueTc2vd87cyPf8vNYTgkzz1iPzJC21qBd2LRvHCsEUXzYRk9PMGFRF6RxtKw== X-Received: by 2002:adf:f14b:: with SMTP id y11mr767664wro.80.1614216830081; Wed, 24 Feb 2021 17:33:50 -0800 (PST) Received: from localhost ([2a02:8084:20e2:c380:d15:339e:aa10:60f1]) by smtp.gmail.com with ESMTPSA id d7sm5992845wrm.62.2021.02.24.17.33.48 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 24 Feb 2021 17:33:48 -0800 (PST) From: "Basil L. Contovounesios" To: bug-gnu-emacs@gnu.org Subject: 28.0.50; Speed up json.el encoding Date: Thu, 25 Feb 2021 01:33:47 +0000 Message-ID: <87a6rtszgk.fsf@tcd.ie> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Received-SPF: none client-ip=2a00:1450:4864:20::429; envelope-from=contovob@tcd.ie; helo=mail-wr1-x429.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: submit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) --=-=-= Content-Type: text/plain Severity: wishlist Tags: patch The attached patch speeds up json-encode by inserting into a buffer rather than concatenating strings. It does so backward compatibly by creating a new json--print-* namespace that mirrors the existing json-encode-* namespace, cleaning it up a bit and reducing code duplication in the process. Using my usual benchmark from bug#40693#89: canada.json old (1.412693239 96 0.736882091) new (1.154423962 32 0.248241551) citm_catalog.json old (0.676292855 68 0.5285956769999993) new (0.306573098 12 0.0965493740000003) twitter.json old (0.353447016 40 0.28536439900000055) new (0.142140227 8 0.05943713899999992) Note that one of the unit tests depends on the patch to map.el in bug#46754 in order to pass. WDYT? Thanks, -- Basil --=-=-= Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename=0001-Speed-up-json.el-encoding.patch Content-Transfer-Encoding: quoted-printable >From 3958c8757e9ee8c6be06c5b6dac371e38978501f Mon Sep 17 00:00:00 2001 From: "Basil L. Contovounesios" Date: Sun, 21 Feb 2021 20:10:08 +0000 Subject: [PATCH] Speed up json.el encoding This replaces most json-encode-* functions with similar json--print-* counterparts that insert into the current buffer instead of returning a string. Some unused but useful json-encode-* functions are kept for backward compatibility and as a public API, and the rest are deprecated. * etc/NEWS: Announce obsoletions. * lisp/json.el: Document organization of library. Make subsection headings more consistent. (json--encoding-current-indentation): Rename... (json--print-indentation-prefix): ...to this, to reflect new use. (json--encode-stringlike, json--encode-alist): Rename... (json--print-stringlike, json--print-alist): ...to these, respectively, and encode argument into current buffer instead. All callers changed. (json--print-string, json--print-unordered-map, json--print-array) (json--print): New functions. (json-encode-string, json-encode-plist, json-encode-array) (json-encode): Use them, respectively. (json-encode-number, json-encode-hash-table): Mark as obsolete aliases of json-encode. (json-encode-key, json-encode-list): Mark as obsolete in preference for json-encode. (json--print-indentation-depth, json--print-keyval-separator): New variables. (json--with-output-to-string): New macro. (json--print-indentation, json--print-keyword, json--print-key) (json--print-pair, json--print-map, json--print-list): New functions. (json--with-indentation): Use json--print-indentation-depth to avoid unnecessary string allocation. (json-encoding-default-indentation, json-pretty-print-max-secs): Clarify docstrings. (json--escape, json--long-string-threshold, json--string-buffer): Remove; no longer used. * lisp/progmodes/js.el (js--js-encode-value): Replace json-encode-string and json-encode-number with json-encode. (js-eval-defun): Use json--print-list to avoid json-encode-list->insert roundtrip. * test/lisp/json-tests.el (test-json-encode-number) (test-json-encode-hash-table, test-json-encode-hash-table-pretty) (test-json-encode-hash-table-lisp-style) (test-json-encode-hash-table-sort, test-json-encode-list): Replace uses of obsolete functions with the equivalent use of json-encode. (test-json-encode-key): Suppress obsoletion warnings. --- etc/NEWS | 10 ++ lisp/json.el | 368 +++++++++++++++++++++------------------- lisp/progmodes/js.el | 6 +- test/lisp/json-tests.el | 184 ++++++++++---------- 4 files changed, 296 insertions(+), 272 deletions(-) diff --git a/etc/NEWS b/etc/NEWS index 52c32768af..1fd0873f4e 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -1529,6 +1529,16 @@ component are now rejected by 'json-read' and friend= s. This makes them more compliant with the JSON specification and consistent with the native JSON parsing functions. =20 +--- +*** Some JSON encoding functions are now obsolete. +The functions 'json-encode-number', 'json-encode-hash-table', +'json-encode-key', and 'json-encode-list' are now obsolete. + +The first two are kept as aliases of 'json-encode', which should be +used instead. Uses of 'json-encode-list' should be changed to call +one of 'json-encode', 'json-encode-alist', 'json-encode-plist', or +'json-encode-array' instead. + ** xml.el =20 *** XML serialization functions now reject invalid characters. diff --git a/lisp/json.el b/lisp/json.el index f20123fcfb..eb655162d3 100644 --- a/lisp/json.el +++ b/lisp/json.el @@ -40,6 +40,17 @@ ;; Similarly, since `false' and `null' are distinct in JSON, you can ;; distinguish them by binding `json-false' and `json-null' as desired. =20 +;;; Organization: + +;; Historically json.el used the prefix `json-read-' for decoding and +;; the prefix `json-encode-' for encoding. Many of these definitions +;; are used by external packages since few were marked as internal. +;; Optimizing the encoder to manipulate a buffer rather than strings +;; while minimizing code duplication therefore necessitated a new +;; namespace `json--print-'. This rendered many encoding functions +;; obsolete and unused, but those considered externally useful are +;; kept for backward compatibility and as a public API. + ;;; History: =20 ;; 2006-03-11 - Initial version. @@ -57,7 +68,7 @@ (require 'map) (require 'subr-x) =20 -;; Parameters +;;;; Parameters =20 (defvar json-object-type 'alist "Type to convert JSON objects to. @@ -102,13 +113,22 @@ json-encoding-separator "Value to use as an element separator when encoding.") =20 (defvar json-encoding-default-indentation " " - "The default indentation level for encoding. + "String used for a single indentation level during encoding. +This value is repeated for each further nested element. Used only when `json-encoding-pretty-print' is non-nil.") =20 -(defvar json--encoding-current-indentation "\n" - "Internally used to keep track of the current indentation level of encod= ing. +(defvar json--print-indentation-prefix "\n" + "String used to start indentation during encoding. Used only when `json-encoding-pretty-print' is non-nil.") =20 +(defvar json--print-indentation-depth 0 + "Current indentation level during encoding. +Dictates repetitions of `json-encoding-default-indentation'. +Used only when `json-encoding-pretty-print' is non-nil.") + +(defvar json--print-keyval-separator ":" + "String used to separate key-value pairs during encoding.") + (defvar json-encoding-pretty-print nil "If non-nil, then the output of `json-encode' will be pretty-printed.") =20 @@ -137,7 +157,7 @@ json-post-element-read-function =20 =20 -;;; Utilities +;;;; Utilities =20 (define-obsolete-function-alias 'json-join #'string-join "28.1") =20 @@ -169,18 +189,38 @@ json--plist-nreverse (setcdr (cdr plist) prev))) plist) =20 +;; Encoder utilities + +(defmacro json--with-output-to-string (&rest body) + "Eval BODY in a temporary buffer bound to `standard-output'. +Return the resulting buffer contents as a string." + (declare (indent 0) (debug t)) + `(with-output-to-string + (with-current-buffer standard-output + ;; This affords decent performance gains. + (setq-local inhibit-modification-hooks t) + ,@body))) + (defmacro json--with-indentation (&rest body) - "Evaluate BODY with the correct indentation for JSON encoding. -This macro binds `json--encoding-current-indentation' according -to `json-encoding-pretty-print' around BODY." + "Eval BODY with the JSON encoding nesting incremented by one step. +This macro sets up appropriate variable bindings for +`json--print-indentation' to produce the correct indentation when +`json-encoding-pretty-print' is non-nil." (declare (debug t) (indent 0)) - `(let ((json--encoding-current-indentation - (if json-encoding-pretty-print - (concat json--encoding-current-indentation - json-encoding-default-indentation) - ""))) + `(let ((json--print-indentation-prefix + (if json-encoding-pretty-print json--print-indentation-prefix ""= )) + (json--print-keyval-separator (if json-encoding-pretty-print ": "= ":")) + (json--print-indentation-depth (1+ json--print-indentation-depth)= )) ,@body)) =20 +(defun json--print-indentation () + "Insert the current indentation for JSON encoding at point. +Has no effect if `json-encoding-pretty-print' is nil." + (when json-encoding-pretty-print + (insert json--print-indentation-prefix) + (dotimes (_ json--print-indentation-depth) + (insert json-encoding-default-indentation)))) + ;; Reader utilities =20 (define-inline json-advance (&optional n) @@ -210,8 +250,6 @@ json-skip-whitespace ;; definition of whitespace in JSON. (inline-quote (skip-chars-forward "\t\n\r "))) =20 - - ;; Error conditions =20 (define-error 'json-error "Unknown JSON error") @@ -228,7 +266,7 @@ 'json-end-of-file =20 =20 -;;; Paths +;;;; Paths =20 (defvar json--path '() "Keeps track of the path during recursive calls to `json-read'. @@ -283,7 +321,9 @@ json-path-to-position (when (plist-get path :path) path)))) =20 -;;; Keywords + + +;;;; Keywords =20 (defconst json-keywords '("true" "false" "null") "List of JSON keywords.") @@ -316,7 +356,13 @@ json-encode-keyword ((eq keyword json-false) "false") ((eq keyword json-null) "null"))) =20 -;;; Numbers +(defun json--print-keyword (keyword) + "Insert KEYWORD as a JSON value at point. +Return nil if KEYWORD is not recognized as a JSON keyword." + (prog1 (setq keyword (json-encode-keyword keyword)) + (and keyword (insert keyword)))) + +;;;; Numbers =20 ;; Number parsing =20 @@ -339,10 +385,9 @@ json-read-number =20 ;; Number encoding =20 -(defalias 'json-encode-number #'number-to-string - "Return a JSON representation of NUMBER.") +(define-obsolete-function-alias 'json-encode-number #'json-encode "28.1") =20 -;;; Strings +;;;; Strings =20 (defconst json-special-chars '((?\" . ?\") @@ -410,65 +455,52 @@ json-read-string =20 ;; String encoding =20 -;; Escape only quotation mark, backslash, and the control -;; characters U+0000 to U+001F (RFC 4627, ECMA-404). -(rx-define json--escape (in ?\" ?\\ cntrl)) - -(defvar json--long-string-threshold 200 - "Length above which strings are considered long for JSON encoding. -It is generally faster to manipulate such strings in a buffer -rather than directly.") - -(defvar json--string-buffer nil - "Buffer used for encoding Lisp strings as JSON. -Initialized lazily by `json-encode-string'.") +(defun json--print-string (string &optional from) + "Insert a JSON representation of STRING at point. +FROM is the index of STRING to start from and defaults to 0." + (goto-char (prog1 (1+ (point)) + ;; Strip `read-only' property (bug#43549). + (insert ?\" (substring-no-properties string from)))) + ;; Escape only quotation mark, backslash, and the control + ;; characters U+0000 to U+001F (RFC 4627, ECMA-404). + (while (re-search-forward (rx (in ?\" ?\\ cntrl)) nil 'move) + (let ((char (preceding-char))) + (delete-char -1) + (insert ?\\ (or + ;; Special JSON character (\n, \r, etc.). + (car (rassq char json-special-chars)) + ;; Fallback: UCS code point in \uNNNN form. + (format "u%04x" char))))) + (insert ?\") + string) =20 (defun json-encode-string (string) "Return a JSON representation of STRING." - ;; Try to avoid buffer overhead in trivial cases, while also - ;; avoiding searching pathological strings for escape characters. - ;; Since `string-match-p' doesn't take a LIMIT argument, we use - ;; string length as our heuristic. See also bug#20154. - (if (and (< (length string) json--long-string-threshold) - (not (string-match-p (rx json--escape) string))) - (concat "\"" (substring-no-properties string) "\"") - (with-current-buffer - (or json--string-buffer - (with-current-buffer (generate-new-buffer " *json-string*" t) - ;; This seems to afford decent performance gains. - (setq-local inhibit-modification-hooks t) - (setq json--string-buffer (current-buffer)))) - ;; Strip `read-only' property (bug#43549). - (insert ?\" (substring-no-properties string)) - (goto-char (1+ (point-min))) - (while (re-search-forward (rx json--escape) nil 'move) - (let ((char (preceding-char))) - (delete-char -1) - (insert ?\\ (or - ;; Special JSON character (\n, \r, etc.). - (car (rassq char json-special-chars)) - ;; Fallback: UCS code point in \uNNNN form. - (format "u%04x" char))))) - (insert ?\") - ;; Empty buffer for next invocation. - (delete-and-extract-region (point-min) (point-max))))) + (json--with-output-to-string (json--print-string string))) =20 -(defun json--encode-stringlike (object) - "Return OBJECT encoded as a JSON string, or nil if not possible." - (cond ((stringp object) (json-encode-string object)) - ((keywordp object) (json-encode-string - (substring (symbol-name object) 1))) - ((symbolp object) (json-encode-string (symbol-name object))))) +(defun json--print-stringlike (object) + "Insert OBJECT encoded as a JSON string at point. +Return nil if OBJECT cannot be encoded as a JSON string." + (cond ((stringp object) (json--print-string object)) + ((keywordp object) (json--print-string (symbol-name object) 1)) + ((symbolp object) (json--print-string (symbol-name object))))) + +(defun json--print-key (object) + "Insert a JSON key representation of OBJECT at point. +Signal `json-key-format' if it cannot be encoded as a string." + (or (json--print-stringlike object) + (signal 'json-key-format (list object)))) =20 (defun json-encode-key (object) "Return a JSON representation of OBJECT. If the resulting JSON object isn't a valid JSON object key, this signals `json-key-format'." - ;; Encoding must be a JSON string. - (or (json--encode-stringlike object) - (signal 'json-key-format (list object)))) + (declare (obsolete json-encode "28.1")) + (json--with-output-to-string (json--print-key object))) =20 -;;; Objects +;;;; Objects + +;; JSON object parsing =20 (defun json-new-object () "Create a new Elisp object corresponding to an empty JSON object. @@ -501,8 +533,6 @@ json-add-to-object ((eq json-object-type 'plist) (cons key (cons value object)))))) =20 -;; JSON object parsing - (defun json-read-object () "Read the JSON object at point." ;; Skip over the '{'. @@ -537,95 +567,81 @@ json-read-object ('plist (json--plist-nreverse elements)) (_ elements)))) =20 +;; JSON object encoding + +(defun json--print-pair (key val) + "Insert JSON representation of KEY-VAL pair at point. +This always inserts a trailing `json-encoding-separator'." + (json--print-indentation) + (json--print-key key) + (insert json--print-keyval-separator) + (json--print val) + (insert json-encoding-separator)) + +(defun json--print-map (map) + "Insert JSON object representation of MAP at point. +This works for any MAP satisfying `mapp'." + (insert ?\{) + (unless (map-empty-p map) + (json--with-indentation + (map-do #'json--print-pair map) + (delete-char (- (length json-encoding-separator)))) + (or json-encoding-lisp-style-closings + (json--print-indentation))) + (insert ?\})) + +(defun json--print-unordered-map (map) + "Like `json--print-map', but optionally sort MAP first. +If `json-encoding-object-sort-predicate' is non-nil, this first +transforms an unsortable MAP into a sortable alist." + (if (and json-encoding-object-sort-predicate + (not (map-empty-p map))) + (json--print-alist (map-pairs map) t) + (json--print-map map))) + ;; Hash table encoding =20 -(defun json-encode-hash-table (hash-table) - "Return a JSON representation of HASH-TABLE." - (cond ((hash-table-empty-p hash-table) "{}") - (json-encoding-object-sort-predicate - (json--encode-alist (map-pairs hash-table) t)) - (t - (let ((kv-sep (if json-encoding-pretty-print ": " ":")) - result) - (json--with-indentation - (maphash - (lambda (k v) - (push (concat json--encoding-current-indentation - (json-encode-key k) - kv-sep - (json-encode v)) - result)) - hash-table)) - (concat "{" - (string-join (nreverse result) json-encoding-separator) - (and json-encoding-pretty-print - (not json-encoding-lisp-style-closings) - json--encoding-current-indentation) - "}"))))) +(define-obsolete-function-alias 'json-encode-hash-table #'json-encode "28.= 1") =20 ;; List encoding (including alists and plists) =20 -(defun json--encode-alist (alist &optional destructive) - "Return a JSON representation of ALIST. -DESTRUCTIVE non-nil means it is safe to modify ALIST by -side-effects." - (when json-encoding-object-sort-predicate - (setq alist (sort (if destructive alist (copy-sequence alist)) - (lambda (a b) - (funcall json-encoding-object-sort-predicate - (car a) (car b)))))) - (concat "{" - (let ((kv-sep (if json-encoding-pretty-print ": " ":"))) - (json--with-indentation - (mapconcat (lambda (cons) - (concat json--encoding-current-indentation - (json-encode-key (car cons)) - kv-sep - (json-encode (cdr cons)))) - alist - json-encoding-separator))) - (and json-encoding-pretty-print - (not json-encoding-lisp-style-closings) - json--encoding-current-indentation) - "}")) +(defun json--print-alist (alist &optional destructive) + "Insert a JSON representation of ALIST at point. +Sort ALIST first if `json-encoding-object-sort-predicate' is +non-nil. Sorting can optionally be DESTRUCTIVE for speed." + (json--print-map (if (and json-encoding-object-sort-predicate alist) + (sort (if destructive alist (copy-sequence alist)) + (lambda (a b) + (funcall json-encoding-object-sort-predicate + (car a) (car b)))) + alist))) + +;; The following two are unused but useful to keep around due to the +;; inherent ambiguity of lists. =20 (defun json-encode-alist (alist) "Return a JSON representation of ALIST." - (if alist (json--encode-alist alist) "{}")) + (json--with-output-to-string (json--print-alist alist))) =20 (defun json-encode-plist (plist) "Return a JSON representation of PLIST." - (cond ((null plist) "{}") - (json-encoding-object-sort-predicate - (json--encode-alist (map-pairs plist) t)) - (t - (let ((kv-sep (if json-encoding-pretty-print ": " ":")) - result) - (json--with-indentation - (while plist - (push (concat json--encoding-current-indentation - (json-encode-key (pop plist)) - kv-sep - (json-encode (pop plist))) - result))) - (concat "{" - (string-join (nreverse result) json-encoding-separator) - (and json-encoding-pretty-print - (not json-encoding-lisp-style-closings) - json--encoding-current-indentation) - "}"))))) + (json--with-output-to-string (json--print-unordered-map plist))) + +(defun json--print-list (list) + "Like `json-encode-list', but insert the JSON at point." + (cond ((json-alist-p list) (json--print-alist list)) + ((json-plist-p list) (json--print-unordered-map list)) + ((listp list) (json--print-array list)) + ((signal 'json-error (list list))))) =20 (defun json-encode-list (list) "Return a JSON representation of LIST. -Tries to DWIM: simple lists become JSON arrays, while alists and plists -become JSON objects." - (cond ((json-alist-p list) (json-encode-alist list)) - ((json-plist-p list) (json-encode-plist list)) - ((listp list) (json-encode-array list)) - (t - (signal 'json-error (list list))))) +Tries to DWIM: alists and plists become JSON objects, while +simple lists become JSON arrays." + (declare (obsolete json-encode "28.1")) + (json--with-output-to-string (json--print-list list))) =20 -;;; Arrays +;;;; Arrays =20 ;; Array parsing =20 @@ -658,28 +674,32 @@ json-read-array =20 ;; Array encoding =20 +(defun json--print-array (array) + "Like `json-encode-array', but insert the JSON at point." + (insert ?\[) + (unless (length=3D array 0) + (json--with-indentation + (json--print-indentation) + (let ((first t)) + (mapc (lambda (elt) + (if first + (setq first nil) + (insert json-encoding-separator) + (json--print-indentation)) + (json--print elt)) + array))) + (or json-encoding-lisp-style-closings + (json--print-indentation))) + (insert ?\])) + (defun json-encode-array (array) "Return a JSON representation of ARRAY. ARRAY can also be a list." - (if (and json-encoding-pretty-print - (not (length=3D array 0))) - (concat - "[" - (json--with-indentation - (concat json--encoding-current-indentation - (mapconcat #'json-encode array - (concat json-encoding-separator - json--encoding-current-indentation)))) - (unless json-encoding-lisp-style-closings - json--encoding-current-indentation) - "]") - (concat "[" - (mapconcat #'json-encode array json-encoding-separator) - "]"))) + (json--with-output-to-string (json--print-array array))) =20 =20 -;;; Reader +;;;; Reader =20 (defmacro json-readtable-dispatch (char) "Dispatch reader function for CHAR at point. @@ -735,7 +755,17 @@ json-read-file =20 =20 -;;; Encoder +;;;; Encoder + +(defun json--print (object) + "Like `json-encode', but insert or print the JSON at point." + (cond ((json--print-keyword object)) + ((listp object) (json--print-list object)) + ((json--print-stringlike object)) + ((numberp object) (prin1 object)) + ((arrayp object) (json--print-array object)) + ((hash-table-p object) (json--print-unordered-map object)) + ((signal 'json-error (list object))))) =20 (defun json-encode (object) "Return a JSON representation of OBJECT as a string. @@ -743,15 +773,9 @@ json-encode OBJECT should have a structure like one returned by `json-read'. If an error is detected during encoding, an error based on `json-error' is signaled." - (cond ((json-encode-keyword object)) - ((listp object) (json-encode-list object)) - ((json--encode-stringlike object)) - ((numberp object) (json-encode-number object)) - ((arrayp object) (json-encode-array object)) - ((hash-table-p object) (json-encode-hash-table object)) - (t (signal 'json-error (list object))))) + (json--with-output-to-string (json--print object))) =20 -;;; Pretty printing & minimizing +;;;; Pretty printing & minimizing =20 (defun json-pretty-print-buffer (&optional minimize) "Pretty-print current buffer. @@ -762,7 +786,7 @@ json-pretty-print-buffer (defvar json-pretty-print-max-secs 2.0 "Maximum time for `json-pretty-print's comparison. The function `json-pretty-print' uses `replace-region-contents' -(which see) passing the value of this variable as argument +\(which see) passing the value of this variable as argument MAX-SECS.") =20 (defun json-pretty-print (begin end &optional minimize) diff --git a/lisp/progmodes/js.el b/lisp/progmodes/js.el index 21bda08680..059122df4f 100644 --- a/lisp/progmodes/js.el +++ b/lisp/progmodes/js.el @@ -3699,8 +3699,7 @@ js--js-encode-value Strings and numbers are JSON-encoded. Lists (including nil) are made into JavaScript array literals and their contents encoded with `js--js-encode-value'." - (cond ((stringp x) (json-encode-string x)) - ((numberp x) (json-encode-number x)) + (cond ((or (stringp x) (numberp x)) (json-encode x)) ((symbolp x) (format "{objid:%S}" (symbol-name x))) ((js--js-handle-p x) =20 @@ -4390,7 +4389,8 @@ js-eval-defun (with-temp-buffer (insert js--js-inserter) (insert "(") - (insert (json-encode-list defun-info)) + (let ((standard-output (current-buffer))) + (json--print-list defun-info)) (insert ",\n") (insert defun-body) (insert "\n)") diff --git a/test/lisp/json-tests.el b/test/lisp/json-tests.el index 9886dc0d45..c2392e1683 100644 --- a/test/lisp/json-tests.el +++ b/test/lisp/json-tests.el @@ -329,13 +329,13 @@ test-json-read-number-invalid (should (equal (read str) res))))))) =20 (ert-deftest test-json-encode-number () - (should (equal (json-encode-number 0) "0")) - (should (equal (json-encode-number -0) "0")) - (should (equal (json-encode-number 3) "3")) - (should (equal (json-encode-number -5) "-5")) - (should (equal (json-encode-number 123.456) "123.456")) + (should (equal (json-encode 0) "0")) + (should (equal (json-encode -0) "0")) + (should (equal (json-encode 3) "3")) + (should (equal (json-encode -5) "-5")) + (should (equal (json-encode 123.456) "123.456")) (let ((bignum (1+ most-positive-fixnum))) - (should (equal (json-encode-number bignum) + (should (equal (json-encode bignum) (number-to-string bignum))))) =20 ;;; Strings @@ -421,27 +421,28 @@ test-json-encode-string "\"\\nasd=D1=84=D1=8B=D0=B2\\u001f\u007ffgh\\t\""))) =20 (ert-deftest test-json-encode-key () - (should (equal (json-encode-key '##) "\"\"")) - (should (equal (json-encode-key :) "\"\"")) - (should (equal (json-encode-key "") "\"\"")) - (should (equal (json-encode-key 'a) "\"a\"")) - (should (equal (json-encode-key :a) "\"a\"")) - (should (equal (json-encode-key "a") "\"a\"")) - (should (equal (json-encode-key t) "\"t\"")) - (should (equal (json-encode-key :t) "\"t\"")) - (should (equal (json-encode-key "t") "\"t\"")) - (should (equal (json-encode-key nil) "\"nil\"")) - (should (equal (json-encode-key :nil) "\"nil\"")) - (should (equal (json-encode-key "nil") "\"nil\"")) - (should (equal (json-encode-key ":a") "\":a\"")) - (should (equal (json-encode-key ":t") "\":t\"")) - (should (equal (json-encode-key ":nil") "\":nil\"")) - (should (equal (should-error (json-encode-key 5)) - '(json-key-format 5))) - (should (equal (should-error (json-encode-key ["foo"])) - '(json-key-format ["foo"]))) - (should (equal (should-error (json-encode-key '("foo"))) - '(json-key-format ("foo"))))) + (with-suppressed-warnings ((obsolete json-encode-key)) + (should (equal (json-encode-key '##) "\"\"")) + (should (equal (json-encode-key :) "\"\"")) + (should (equal (json-encode-key "") "\"\"")) + (should (equal (json-encode-key 'a) "\"a\"")) + (should (equal (json-encode-key :a) "\"a\"")) + (should (equal (json-encode-key "a") "\"a\"")) + (should (equal (json-encode-key t) "\"t\"")) + (should (equal (json-encode-key :t) "\"t\"")) + (should (equal (json-encode-key "t") "\"t\"")) + (should (equal (json-encode-key nil) "\"nil\"")) + (should (equal (json-encode-key :nil) "\"nil\"")) + (should (equal (json-encode-key "nil") "\"nil\"")) + (should (equal (json-encode-key ":a") "\":a\"")) + (should (equal (json-encode-key ":t") "\":t\"")) + (should (equal (json-encode-key ":nil") "\":nil\"")) + (should (equal (should-error (json-encode-key 5)) + '(json-key-format 5))) + (should (equal (should-error (json-encode-key ["foo"])) + '(json-key-format ["foo"]))) + (should (equal (should-error (json-encode-key '("foo"))) + '(json-key-format ("foo")))))) =20 ;;; Objects =20 @@ -578,45 +579,32 @@ test-json-read-object-function (ert-deftest test-json-encode-hash-table () (let ((json-encoding-object-sort-predicate nil) (json-encoding-pretty-print nil)) - (should (equal (json-encode-hash-table #s(hash-table)) "{}")) - (should (equal (json-encode-hash-table #s(hash-table data (a 1))) + (should (equal (json-encode #s(hash-table)) "{}")) + (should (equal (json-encode #s(hash-table data (a 1))) "{\"a\":1}")) + (should (equal (json-encode #s(hash-table data (t 1))) "{\"t\":1}")) + (should (equal (json-encode #s(hash-table data (nil 1))) "{\"nil\":1}"= )) + (should (equal (json-encode #s(hash-table data (:a 1))) "{\"a\":1}")) + (should (equal (json-encode #s(hash-table data (:t 1))) "{\"t\":1}")) + (should (equal (json-encode #s(hash-table data (:nil 1))) "{\"nil\":1}= ")) + (should (equal (json-encode #s(hash-table test equal data ("a" 1))) "{\"a\":1}")) - (should (equal (json-encode-hash-table #s(hash-table data (t 1))) + (should (equal (json-encode #s(hash-table test equal data ("t" 1))) "{\"t\":1}")) - (should (equal (json-encode-hash-table #s(hash-table data (nil 1))) + (should (equal (json-encode #s(hash-table test equal data ("nil" 1))) "{\"nil\":1}")) - (should (equal (json-encode-hash-table #s(hash-table data (:a 1))) - "{\"a\":1}")) - (should (equal (json-encode-hash-table #s(hash-table data (:t 1))) - "{\"t\":1}")) - (should (equal (json-encode-hash-table #s(hash-table data (:nil 1))) - "{\"nil\":1}")) - (should (equal (json-encode-hash-table - #s(hash-table test equal data ("a" 1))) - "{\"a\":1}")) - (should (equal (json-encode-hash-table - #s(hash-table test equal data ("t" 1))) - "{\"t\":1}")) - (should (equal (json-encode-hash-table - #s(hash-table test equal data ("nil" 1))) - "{\"nil\":1}")) - (should (equal (json-encode-hash-table - #s(hash-table test equal data (":a" 1))) + (should (equal (json-encode #s(hash-table test equal data (":a" 1))) "{\":a\":1}")) - (should (equal (json-encode-hash-table - #s(hash-table test equal data (":t" 1))) + (should (equal (json-encode #s(hash-table test equal data (":t" 1))) "{\":t\":1}")) - (should (equal (json-encode-hash-table - #s(hash-table test equal data (":nil" 1))) + (should (equal (json-encode #s(hash-table test equal data (":nil" 1))) "{\":nil\":1}")) - (should (member (json-encode-hash-table #s(hash-table data (t 2 :nil 1= ))) + (should (member (json-encode #s(hash-table data (t 2 :nil 1))) '("{\"nil\":1,\"t\":2}" "{\"t\":2,\"nil\":1}"))) - (should (member (json-encode-hash-table - #s(hash-table test equal data (:t 2 ":t" 1))) + (should (member (json-encode #s(hash-table test equal data (:t 2 ":t" = 1))) '("{\":t\":1,\"t\":2}" "{\"t\":2,\":t\":1}"))) - (should (member (json-encode-hash-table #s(hash-table data (b 2 a 1))) + (should (member (json-encode #s(hash-table data (b 2 a 1))) '("{\"a\":1,\"b\":2}" "{\"b\":2,\"a\":1}"))) - (should (member (json-encode-hash-table #s(hash-table data (c 3 b 2 a = 1))) + (should (member (json-encode #s(hash-table data (c 3 b 2 a 1))) '("{\"a\":1,\"b\":2,\"c\":3}" "{\"a\":1,\"c\":3,\"b\":2}" "{\"b\":2,\"a\":1,\"c\":3}" @@ -629,13 +617,12 @@ test-json-encode-hash-table-pretty (json-encoding-pretty-print t) (json-encoding-default-indentation " ") (json-encoding-lisp-style-closings nil)) - (should (equal (json-encode-hash-table #s(hash-table)) "{}")) - (should (equal (json-encode-hash-table #s(hash-table data (a 1))) - "{\n \"a\": 1\n}")) - (should (member (json-encode-hash-table #s(hash-table data (b 2 a 1))) + (should (equal (json-encode #s(hash-table)) "{}")) + (should (equal (json-encode #s(hash-table data (a 1))) "{\n \"a\": 1\n= }")) + (should (member (json-encode #s(hash-table data (b 2 a 1))) '("{\n \"a\": 1,\n \"b\": 2\n}" "{\n \"b\": 2,\n \"a\": 1\n}"))) - (should (member (json-encode-hash-table #s(hash-table data (c 3 b 2 a = 1))) + (should (member (json-encode #s(hash-table data (c 3 b 2 a 1))) '("{\n \"a\": 1,\n \"b\": 2,\n \"c\": 3\n}" "{\n \"a\": 1,\n \"c\": 3,\n \"b\": 2\n}" "{\n \"b\": 2,\n \"a\": 1,\n \"c\": 3\n}" @@ -648,13 +635,12 @@ test-json-encode-hash-table-lisp-style (json-encoding-pretty-print t) (json-encoding-default-indentation " ") (json-encoding-lisp-style-closings t)) - (should (equal (json-encode-hash-table #s(hash-table)) "{}")) - (should (equal (json-encode-hash-table #s(hash-table data (a 1))) - "{\n \"a\": 1}")) - (should (member (json-encode-hash-table #s(hash-table data (b 2 a 1))) + (should (equal (json-encode #s(hash-table)) "{}")) + (should (equal (json-encode #s(hash-table data (a 1))) "{\n \"a\": 1}"= )) + (should (member (json-encode #s(hash-table data (b 2 a 1))) '("{\n \"a\": 1,\n \"b\": 2}" "{\n \"b\": 2,\n \"a\": 1}"))) - (should (member (json-encode-hash-table #s(hash-table data (c 3 b 2 a = 1))) + (should (member (json-encode #s(hash-table data (c 3 b 2 a 1))) '("{\n \"a\": 1,\n \"b\": 2,\n \"c\": 3}" "{\n \"a\": 1,\n \"c\": 3,\n \"b\": 2}" "{\n \"b\": 2,\n \"a\": 1,\n \"c\": 3}" @@ -672,7 +658,7 @@ test-json-encode-hash-table-sort (#s(hash-table data (c 3 b 2 a 1)) . "{\"a\":1,\"b\":2,\"c\":3}"))) (let ((copy (map-pairs in))) - (should (equal (json-encode-hash-table in) out)) + (should (equal (json-encode in) out)) ;; Ensure sorting isn't destructive. (should (seq-set-equal-p (map-pairs in) copy)))))) =20 @@ -785,38 +771,42 @@ test-json-encode-plist-sort (should (equal in copy)))))) =20 (ert-deftest test-json-encode-list () + "Test `json-encode-list' or its more moral equivalents." (let ((json-encoding-object-sort-predicate nil) (json-encoding-pretty-print nil)) - (should (equal (json-encode-list ()) "{}")) - (should (equal (json-encode-list '(a)) "[\"a\"]")) - (should (equal (json-encode-list '(:a)) "[\"a\"]")) - (should (equal (json-encode-list '("a")) "[\"a\"]")) - (should (equal (json-encode-list '(a 1)) "[\"a\",1]")) - (should (equal (json-encode-list '("a" 1)) "[\"a\",1]")) - (should (equal (json-encode-list '(:a 1)) "{\"a\":1}")) - (should (equal (json-encode-list '((a . 1))) "{\"a\":1}")) - (should (equal (json-encode-list '((:a . 1))) "{\"a\":1}")) - (should (equal (json-encode-list '(:b 2 :a)) "[\"b\",2,\"a\"]")) - (should (equal (json-encode-list '(4 3 2 1)) "[4,3,2,1]")) - (should (equal (json-encode-list '(b 2 a 1)) "[\"b\",2,\"a\",1]")) - (should (equal (json-encode-list '(:b 2 :a 1)) "{\"b\":2,\"a\":1}")) - (should (equal (json-encode-list '((b . 2) (a . 1))) "{\"b\":2,\"a\":1= }")) - (should (equal (json-encode-list '((:b . 2) (:a . 1))) + ;; Trick `json-encode' into using `json--print-list'. + (let ((json-null (list nil))) + (should (equal (json-encode ()) "{}"))) + (should (equal (json-encode '(a)) "[\"a\"]")) + (should (equal (json-encode '(:a)) "[\"a\"]")) + (should (equal (json-encode '("a")) "[\"a\"]")) + (should (equal (json-encode '(a 1)) "[\"a\",1]")) + (should (equal (json-encode '("a" 1)) "[\"a\",1]")) + (should (equal (json-encode '(:a 1)) "{\"a\":1}")) + (should (equal (json-encode '((a . 1))) "{\"a\":1}")) + (should (equal (json-encode '((:a . 1))) "{\"a\":1}")) + (should (equal (json-encode '(:b 2 :a)) "[\"b\",2,\"a\"]")) + (should (equal (json-encode '(4 3 2 1)) "[4,3,2,1]")) + (should (equal (json-encode '(b 2 a 1)) "[\"b\",2,\"a\",1]")) + (should (equal (json-encode '(:b 2 :a 1)) "{\"b\":2,\"a\":1}")) + (should (equal (json-encode '((b . 2) (a . 1))) "{\"b\":2,\"a\":1}")) + (should (equal (json-encode '((:b . 2) (:a . 1))) "{\"b\":2,\"a\":1}")) - (should (equal (json-encode-list '((a) 1)) "[[\"a\"],1]")) - (should (equal (json-encode-list '((:a) 1)) "[[\"a\"],1]")) - (should (equal (json-encode-list '(("a") 1)) "[[\"a\"],1]")) - (should (equal (json-encode-list '((a 1) 2)) "[[\"a\",1],2]")) - (should (equal (json-encode-list '((:a 1) 2)) "[{\"a\":1},2]")) - (should (equal (json-encode-list '(((a . 1)) 2)) "[{\"a\":1},2]")) - (should (equal (json-encode-list '(:a 1 :b (2))) "{\"a\":1,\"b\":[2]}"= )) - (should (equal (json-encode-list '((a . 1) (b 2))) "{\"a\":1,\"b\":[2]= }")) - (should-error (json-encode-list '(a . 1)) :type 'wrong-type-argument) - (should-error (json-encode-list '((a . 1) 2)) :type 'wrong-type-argume= nt) - (should (equal (should-error (json-encode-list [])) - '(json-error []))) - (should (equal (should-error (json-encode-list [a])) - '(json-error [a]))))) + (should (equal (json-encode '((a) 1)) "[[\"a\"],1]")) + (should (equal (json-encode '((:a) 1)) "[[\"a\"],1]")) + (should (equal (json-encode '(("a") 1)) "[[\"a\"],1]")) + (should (equal (json-encode '((a 1) 2)) "[[\"a\",1],2]")) + (should (equal (json-encode '((:a 1) 2)) "[{\"a\":1},2]")) + (should (equal (json-encode '(((a . 1)) 2)) "[{\"a\":1},2]")) + (should (equal (json-encode '(:a 1 :b (2))) "{\"a\":1,\"b\":[2]}")) + (should (equal (json-encode '((a . 1) (b 2))) "{\"a\":1,\"b\":[2]}")) + (should-error (json-encode '(a . 1)) :type 'wrong-type-argument) + (should-error (json-encode '((a . 1) 2)) :type 'wrong-type-argument) + (with-suppressed-warnings ((obsolete json-encode-list)) + (should (equal (should-error (json-encode-list [])) + '(json-error []))) + (should (equal (should-error (json-encode-list [a])) + '(json-error [a])))))) =20 ;;; Arrays =20 --=20 2.30.0 --=-=-=-- From debbugs-submit-bounces@debbugs.gnu.org Thu Feb 25 13:21:32 2021 Received: (at 46761) by debbugs.gnu.org; 25 Feb 2021 18:21:32 +0000 Received: from localhost ([127.0.0.1]:39223 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lFLGV-000721-S4 for submit@debbugs.gnu.org; Thu, 25 Feb 2021 13:21:32 -0500 Received: from mail-wm1-f43.google.com ([209.85.128.43]:51300) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lFLGS-00071m-UV for 46761@debbugs.gnu.org; Thu, 25 Feb 2021 13:21:31 -0500 Received: by mail-wm1-f43.google.com with SMTP id g11so1692415wmh.1 for <46761@debbugs.gnu.org>; Thu, 25 Feb 2021 10:21:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tcd.ie; s=google21; h=from:to:subject:references:date:in-reply-to:message-id:user-agent :mime-version; bh=oNhyEoebcn38DeRCE4wc0+PgMlLLZ1kCGhGm311fHgE=; b=DsdZmLZ7KrNSN51DwngYcATLcYyFyl/TfE36/VLpd/wt4EXvBgM2zXegad3stVpV2S 2qkFbfHV3F8jLe82OyqFdhQYf7lNBAA5NXSPjYEINXp728k7mAqK7oUDO8/9cgSf7xXo GllcjUEtyBwc1QmRnDFrwG/t/NW1gRP4qG2nidR0yPefv3m5DbPtmoHdjmZPqfgb3dY8 WgC5nLdlIpshRFI17oKlNhiXQeyrvLXb5fJsXAEpT+UZvhZ6iwObeLYBfl5fNaMskiri T8rjI773fhcANrdHRR3AbQjuzLFvyiDBXX6zWN5GRd+66FOuoe67luQpW42/1DUCpZ3j IuOQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:references:date:in-reply-to :message-id:user-agent:mime-version; bh=oNhyEoebcn38DeRCE4wc0+PgMlLLZ1kCGhGm311fHgE=; b=dfVLefpOfoP1IYcKFdFp5Twg8KRGBLn3PXzuWrXrZC76vZ8xsvPVtnFvmx071kdDqA 9by8dYNR/cy8Dv7UXtUwjHP/GjPtlH2Q2e/mUm65pVZ44wsfnyL4vw+QSwqUaePN69ja n4/pAczKuMMA/U6AnvoU5S+Wj/VSXnby/QiY9nGLCEbL+Er8/9YwOjHSKXXfna+zz2fF UVsiDPiWzR3DOq2KFgyXGVwkPlt0ftAvTweO0YtBwWBELqKlQv5s155vpGDi4AtqQwfB cbxjuxopRRSQDqu5yWBiwqSfp/VC5kQZ59LDDmBt5sSgjtE/1H+04qaiKYVdK6jbHSpU 4GMw== X-Gm-Message-State: AOAM533ZNotWVzGH8XMPcaCTMKaZKyszUTUNdnAIjnlAC/q7ENmk5XJ2 X55lMGuJgUT4JQYlEj3kdtrHZUJ0vjsOkg== X-Google-Smtp-Source: ABdhPJzLh8sS9hxVi9Y1qNGlQDWKRGt9Focmb1YnZY+AUOrxCSLISsAgS4r+lBZcI9MIupovnHGpkw== X-Received: by 2002:a1c:a916:: with SMTP id s22mr4491949wme.82.1614277282675; Thu, 25 Feb 2021 10:21:22 -0800 (PST) Received: from localhost ([2a02:8084:20e2:c380:d15:339e:aa10:60f1]) by smtp.gmail.com with ESMTPSA id y16sm9469512wrw.46.2021.02.25.10.21.21 for <46761@debbugs.gnu.org> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 25 Feb 2021 10:21:21 -0800 (PST) From: "Basil L. Contovounesios" To: 46761@debbugs.gnu.org Subject: Re: bug#46761: 28.0.50; Speed up json.el encoding References: <87a6rtszgk.fsf@tcd.ie> Date: Thu, 25 Feb 2021 18:21:20 +0000 In-Reply-To: <87a6rtszgk.fsf@tcd.ie> (Basil L. Contovounesios's message of "Thu, 25 Feb 2021 01:33:47 +0000") Message-ID: <87ft1kgg9r.fsf@tcd.ie> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 46761 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) --=-=-= Content-Type: text/plain "Basil L. Contovounesios" writes: > The attached patch speeds up json-encode by inserting into a buffer > rather than concatenating strings. It does so backward compatibly by > creating a new json--print-* namespace that mirrors the existing > json-encode-* namespace, cleaning it up a bit and reducing code > duplication in the process. > > Using my usual benchmark from bug#40693#89: > > canada.json > old (1.412693239 96 0.736882091) > new (1.154423962 32 0.248241551) > > citm_catalog.json > old (0.676292855 68 0.5285956769999993) > new (0.306573098 12 0.0965493740000003) > > twitter.json > old (0.353447016 40 0.28536439900000055) > new (0.142140227 8 0.05943713899999992) This additional change: --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=json.diff diff --git a/lisp/json.el b/lisp/json.el index eb655162d3..461f688f9c 100644 --- a/lisp/json.el +++ b/lisp/json.el @@ -199,6 +199,8 @@ json--with-output-to-string (with-current-buffer standard-output ;; This affords decent performance gains. (setq-local inhibit-modification-hooks t) + ;; Ignore `read-only' property once and for all (bug#43549). + (setq-local inhibit-read-only t) ,@body))) (defmacro json--with-indentation (&rest body) @@ -458,9 +460,9 @@ json-read-string (defun json--print-string (string &optional from) "Insert a JSON representation of STRING at point. FROM is the index of STRING to start from and defaults to 0." - (goto-char (prog1 (1+ (point)) - ;; Strip `read-only' property (bug#43549). - (insert ?\" (substring-no-properties string from)))) + (goto-char (prog1 (1+ (point)) (insert ?\" string))) + (set-text-properties (point) (point-max) ()) + (and from (delete-char from)) ;; Escape only quotation mark, backslash, and the control ;; characters U+0000 to U+001F (RFC 4627, ECMA-404). (while (re-search-forward (rx (in ?\" ?\\ cntrl)) nil 'move) --=-=-= Content-Type: text/plain improves things slightly further (slight inconsistencies with the above are because my laptop's currently on battery power): canada.json old (1.450930341 96 0.7616264250000002) new (1.161926076 32 0.24752529000000045) citm_catalog.json old (0.686048204 68 0.5394565070000006) new (0.267222201 6 0.048179708000000154) twitter.json old (0.362725099 40 0.2935560630000005) new (0.099399607 2 0.01469844000000009) And yes, I have added a test case for this locally. -- Basil --=-=-=-- From debbugs-submit-bounces@debbugs.gnu.org Thu Feb 25 14:36:26 2021 Received: (at 46761) by debbugs.gnu.org; 25 Feb 2021 19:36:26 +0000 Received: from localhost ([127.0.0.1]:39386 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lFMQz-0002XC-Uy for submit@debbugs.gnu.org; Thu, 25 Feb 2021 14:36:26 -0500 Received: from mail-wm1-f46.google.com ([209.85.128.46]:55355) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lFMQw-0002Wy-MT for 46761@debbugs.gnu.org; Thu, 25 Feb 2021 14:36:24 -0500 Received: by mail-wm1-f46.google.com with SMTP id w7so5591049wmb.5 for <46761@debbugs.gnu.org>; Thu, 25 Feb 2021 11:36:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tcd.ie; s=google21; h=from:to:subject:references:date:in-reply-to:message-id:user-agent :mime-version; bh=zpEU8wFewK2BE4XyOZyLcPnKt6MxwQ/bpMh0+2Ouf/Y=; b=X/8qVXPNnvSZXHXlja+pPiCYS3YK2NbSMapaNunWIjzx/MkH1EJ+cBbAUvv32ZMPcS fiapaw8imvnHxxKv28l21+/e8Eppsa7mTGbQwcmUrsHin4aFBotxQK445gEd4KIMJhwC CnmXakjef9uBmG5JQQhm+qfDlKJxkF5Wkw0LdLhTJ96vRcQEEHR9yTIisqvhRqt9kyPK EAUArmsMBTb4pOYUFKi0bvZVkrucH95CQdnobpF5Yn+So7BgZWz8Xz+Fot+gQuUbLajp NC7zrPqNZ6EfQgC7uI6dx8ZTp7gFpl9wkA3j/Lcf4TAZ1PL97jR8x2QHJo1rQA4o0KWd gUUg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:references:date:in-reply-to :message-id:user-agent:mime-version; bh=zpEU8wFewK2BE4XyOZyLcPnKt6MxwQ/bpMh0+2Ouf/Y=; b=PVHfDcVk62eE0aiUYb8O4VYRfKemlHAK+uXAuPr9MBoyMUQsi5ipMSADoqexUF9UtF 3/CXDXHdGoanyE5EGqWXu9W12vTfMsENreADuRQ0FrKgdr/y6mzqVpsYJvS/hhYGntHB StivbzDGOPbXbwLiRYypLekwLoZkHiGYVcTWWe/sB5AbXj/TpofUu6qJ4HPeqWO9P8Bk TOzmhss2zP8UDOmCbm2/sNudZR83yO+nm4Erce9WKvP185riTUYkTdIwZsI6NhiBQjin K6XI1hAgqRxWssJjLsGFPvWiHYEwXSsmnPRreJlPup/2r/T/7ZG3yb53RhmQzHkEcfTJ Gl4A== X-Gm-Message-State: AOAM530WlthlA17DKRBx0s5Wp+KwhYUhpEbOWOh7KtPfv6hkYa6zXHef +wpSgY5A516wdH4rdkVFdx1s8mCg4do31A== X-Google-Smtp-Source: ABdhPJxr0uXMclfmSHJ2QvgUI7oMmt9NGKZ+rifvtkjwha7Mm0l94m74eo1MfzAq1HgOJNHMMnTGDw== X-Received: by 2002:a7b:cc0c:: with SMTP id f12mr3682767wmh.137.1614281776078; Thu, 25 Feb 2021 11:36:16 -0800 (PST) Received: from localhost ([2a02:8084:20e2:c380:d15:339e:aa10:60f1]) by smtp.gmail.com with ESMTPSA id u4sm1070295wrm.24.2021.02.25.11.36.15 for <46761@debbugs.gnu.org> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 25 Feb 2021 11:36:15 -0800 (PST) From: "Basil L. Contovounesios" To: 46761@debbugs.gnu.org Subject: Re: bug#46761: 28.0.50; Speed up json.el encoding References: <87a6rtszgk.fsf@tcd.ie> <87ft1kgg9r.fsf@tcd.ie> Date: Thu, 25 Feb 2021 19:36:14 +0000 In-Reply-To: <87ft1kgg9r.fsf@tcd.ie> (Basil L. Contovounesios's message of "Thu, 25 Feb 2021 18:21:20 +0000") Message-ID: <87a6rsgcsx.fsf@tcd.ie> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 46761 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) "Basil L. Contovounesios" writes: > @@ -458,9 +460,9 @@ json-read-string > (defun json--print-string (string &optional from) > "Insert a JSON representation of STRING at point. > FROM is the index of STRING to start from and defaults to 0." > - (goto-char (prog1 (1+ (point)) > - ;; Strip `read-only' property (bug#43549). > - (insert ?\" (substring-no-properties string from)))) > + (goto-char (prog1 (1+ (point)) (insert ?\" string))) > + (set-text-properties (point) (point-max) ()) > + (and from (delete-char from)) AKA: (insert ?\") (goto-char (prog1 (point) (princ string))) (and from (delete-char from)) -- Basil From debbugs-submit-bounces@debbugs.gnu.org Sat Feb 27 13:51:18 2021 Received: (at 46761) by debbugs.gnu.org; 27 Feb 2021 18:51:18 +0000 Received: from localhost ([127.0.0.1]:45395 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lG4gP-0004Qx-Tr for submit@debbugs.gnu.org; Sat, 27 Feb 2021 13:51:18 -0500 Received: from mail-wm1-f51.google.com ([209.85.128.51]:39555) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lG4gO-0004Qj-4E for 46761@debbugs.gnu.org; Sat, 27 Feb 2021 13:51:17 -0500 Received: by mail-wm1-f51.google.com with SMTP id u125so10580092wmg.4 for <46761@debbugs.gnu.org>; Sat, 27 Feb 2021 10:51:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:subject:to:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=ayvWnH0PWBBSBRB5xsRSSO1EbGcFPpvA6/qIo6ctWpw=; b=sue+LMZxnfqMjbNB5nQ6nbYvUGLcaBkZVCC0BD5q11eqPH5sshlVupk+loyOGadNaA H7Y/TYtKhvtiWHUc+yxwK1p9Ca7nwZlIM5fjLKkcIM1qjDBEyR3VCofwlOLAPMe6Uu+m UvZFptuWjFS/2e2+v1qYCr/k6J5kigbyfZIoj9Xj7L7UuHgP3qVKpyB/iPUZOKcV1+9P 8rQ5Vv7smI4t27n4Iu/AH8WQKCzv7SzW73OuhEWOMbTOJfgVpn8GdJU0k7REYrdYNL/o sFjEx02VXZW2eZi8l+j7FOuXbNVWLHcF0fiPzuovqBllT2c3n2G+aQ8ciEcZ8Txvnb96 KcHw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:subject:to:references:from:message-id :date:user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=ayvWnH0PWBBSBRB5xsRSSO1EbGcFPpvA6/qIo6ctWpw=; b=XVnU51N9t5fY1uEn99mIzQzhaOmPBJfupfRdzRlwC38hoKfzsHxsU90aMFDl/KreGS NHerXhPxTAIvc3WhIwOd9ldiBWv+AeD+ky2G1JIfMheZaDHkXPfWa09YJhTncxaXlOUP 8YggAQDPA3uYjj/Rsu3mUg5TSD9qdZmqrVdZWqJgKDQqQl64+RBr3Cto5ZLtK3+tq8vL L8BHHyBPF/yVGOdfgHZjEuoufx4ghSY5948rgTOGdwr4B9xppnMSO/H1OIYBVw3SCnZc GQ1nk66IT8wG6vhCwU4kGZnpkGNCvCRzQhkalmR33XCZYjHsJ8M7bvs/adPyTjryY6Ux f/ug== X-Gm-Message-State: AOAM532n2f3+4qkRptuAF9Uz3kqG9CnJWN5iAzwtlj/grlXeEnSb7fEU at+2EXLPfLd+pn3UjE/xeBgq8AQhyRI= X-Google-Smtp-Source: ABdhPJzuk+OTWqJT3UeHJj/6IuhjtyCaac5BlCDI9pw9aq8ScsdvF923EeUm2N+MZ6hDCQR6RQyqUA== X-Received: by 2002:a7b:c353:: with SMTP id l19mr8335744wmj.147.1614451870409; Sat, 27 Feb 2021 10:51:10 -0800 (PST) Received: from [192.168.0.6] ([46.251.119.176]) by smtp.googlemail.com with ESMTPSA id x13sm17990688wrt.75.2021.02.27.10.51.09 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sat, 27 Feb 2021 10:51:09 -0800 (PST) Subject: Re: bug#46761: 28.0.50; Speed up json.el encoding To: "Basil L. Contovounesios" , 46761@debbugs.gnu.org References: <87a6rtszgk.fsf@tcd.ie> From: Dmitry Gutov Message-ID: <06140794-3f40-8a35-573d-4414d2611afc@yandex.ru> Date: Sat, 27 Feb 2021 20:51:05 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 MIME-Version: 1.0 In-Reply-To: <87a6rtszgk.fsf@tcd.ie> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-Spam-Score: 0.1 (/) X-Debbugs-Envelope-To: 46761 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.9 (/) On 25.02.2021 03:33, Basil L. Contovounesios wrote: > Severity: wishlist > Tags: patch > > The attached patch speeds up json-encode by inserting into a buffer > rather than concatenating strings. It does so backward compatibly by > creating a new json--print-* namespace that mirrors the existing > json-encode-* namespace, cleaning it up a bit and reducing code > duplication in the process. > > Using my usual benchmark from bug#40693#89: > > canada.json > old (1.412693239 96 0.736882091) > new (1.154423962 32 0.248241551) > > citm_catalog.json > old (0.676292855 68 0.5285956769999993) > new (0.306573098 12 0.0965493740000003) > > twitter.json > old (0.353447016 40 0.28536439900000055) > new (0.142140227 8 0.05943713899999992) > > Note that one of the unit tests depends on the patch to map.el in > bug#46754 in order to pass. Looking good. I'm guessing there is an approximate size where structures smaller than that size will get slower to encode because of this change (creating a temp buffer and switching to it are not entirely free), but I can't think of a use case where this would matter. From debbugs-submit-bounces@debbugs.gnu.org Sat Feb 27 14:31:10 2021 Received: (at 46761) by debbugs.gnu.org; 27 Feb 2021 19:31:11 +0000 Received: from localhost ([127.0.0.1]:45423 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lG5J0-0005NK-N1 for submit@debbugs.gnu.org; Sat, 27 Feb 2021 14:31:10 -0500 Received: from mail-wr1-f45.google.com ([209.85.221.45]:45037) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lG5Iw-0005Mr-VA for 46761@debbugs.gnu.org; Sat, 27 Feb 2021 14:31:08 -0500 Received: by mail-wr1-f45.google.com with SMTP id h98so11850612wrh.11 for <46761@debbugs.gnu.org>; Sat, 27 Feb 2021 11:31:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tcd.ie; s=google21; h=from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version; bh=/ABstaptImsMo6JIJg32Q5I0p/gzMoBRcf8JxwtIquQ=; b=H0NrDTYLZ/lb1fJA1aH8XsZSKjYacekmK3Gf6F+72u1XeoSlw30QyD6FHbnYNES7z9 VChyWt16XkgD85rLHgPgTYoQB79rZEVTAdYf1NU/4nsPruh9oRBivxSTWNxCOJmNHOSy kTEMSkfbmkiXc0/zHEwmABcky4PUOD50chxO6TPb2ZiSEqdzDYPtJC4toS4ZuzjccJE/ 9fi9uz8n+zlrJO4PHmOSb2TwglH6z1PVIfzooGrd2m6zQHDFBT6Ifbb4TJjzTjtCVjq4 S2mkEQ0gUOeZfsnlKDGPGWCnnTRBTbb4++Gkp4Bp9px3OYNFjymy/sBliP9ZepGFhLk8 FPNg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:references:date:in-reply-to :message-id:user-agent:mime-version; bh=/ABstaptImsMo6JIJg32Q5I0p/gzMoBRcf8JxwtIquQ=; b=CbPgiiWXJ43S/w9YKorGXPvaBz/x2SUUKkjhOBPCftxPJqVvFKy7lNyO2pdT6sq/Pa hOJQ/ph6Ibkt66drpOMmdvp0K8DMpe5q8MHTTIlEsIl1jcwg8Is2Exm5Vaq37wl81wai 9HUivAmk5l/flXOQ6ErLYy96xrpLKBFjSc9+IuushsL3ocEzpe5v14XdIS9YKBExomKA NV+aIGS3DHmJ+aJh+3odvoZMekiqxAM0wyeth3c2d0FvBEHOm0RVe9lzJWBV8v+7Vgc0 3ohSN5tzQxIMj5FgO7SjnQAHJIC/QPBHGRygWhVz9vVYaPV+2daID3D4U2zyJLBtI7nz 3hqw== X-Gm-Message-State: AOAM530xwFX5tvy8DlPgGXm4YqKdwaTbb3c7G657ARP2VzEEHf8AEIa3 FhpU+xL2dQ6zmsgin+NfklTdHA== X-Google-Smtp-Source: ABdhPJz9MSHqZ10Xi98FqylHjS7h8RR8S59Fnpq4QIRG4UTLdKTp2XWUpnJf+lZkrxwexFC0hWhWTw== X-Received: by 2002:a5d:66c8:: with SMTP id k8mr9203250wrw.163.1614454261108; Sat, 27 Feb 2021 11:31:01 -0800 (PST) Received: from localhost ([2a02:8084:20e2:c380:d15:339e:aa10:60f1]) by smtp.gmail.com with ESMTPSA id g1sm16353650wmh.9.2021.02.27.11.31.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 27 Feb 2021 11:31:00 -0800 (PST) From: "Basil L. Contovounesios" To: Dmitry Gutov Subject: Re: bug#46761: 28.0.50; Speed up json.el encoding References: <87a6rtszgk.fsf@tcd.ie> <06140794-3f40-8a35-573d-4414d2611afc@yandex.ru> Date: Sat, 27 Feb 2021 19:30:59 +0000 In-Reply-To: <06140794-3f40-8a35-573d-4414d2611afc@yandex.ru> (Dmitry Gutov's message of "Sat, 27 Feb 2021 20:51:05 +0200") Message-ID: <87a6rp1f64.fsf@tcd.ie> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: -0.0 (/) X-Debbugs-Envelope-To: 46761 Cc: 46761@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) Dmitry Gutov writes: > Looking good. Thanks. > I'm guessing there is an approximate size where structures smaller than that > size will get slower to encode because of this change (creating a temp buffer > and switching to it are not entirely free), Of course, e.g. {"a": true}. > but I can't think of a use case where this would matter. Agreed, because by the time a single with-temp-buffer becomes the limiting factor, the encoding time for such small objects is trivially small. -- Basil From debbugs-submit-bounces@debbugs.gnu.org Sat Feb 27 15:01:40 2021 Received: (at 46761) by debbugs.gnu.org; 27 Feb 2021 20:01:40 +0000 Received: from localhost ([127.0.0.1]:45432 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lG5mW-00063u-J1 for submit@debbugs.gnu.org; Sat, 27 Feb 2021 15:01:40 -0500 Received: from mail-wr1-f43.google.com ([209.85.221.43]:38809) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lG5mV-00063j-Mb for 46761@debbugs.gnu.org; Sat, 27 Feb 2021 15:01:40 -0500 Received: by mail-wr1-f43.google.com with SMTP id b3so11919983wrj.5 for <46761@debbugs.gnu.org>; Sat, 27 Feb 2021 12:01:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=mMDLlM26mvl4ryqc/DF04/Gla4zjoqsvj5uvknP9EyM=; b=kQcrdjcX74OsI5c5n7ejFFOTU1K80mIuLJrEG4ecxgeeaN9xbaC6PtRI6kXZBm4N/+ iDfML1rTMUdWb2kZ+378MfABSPg204VaimShuam08UGSTh3B4IhPpewZVD/L4YVgiK96 3M4derDvqXIkt9EHkdRb2A6mcUxPX/r4nbIeYxs5LuXRA4m2ohwIC8ddti/CGEnqV0oc g5ZC8z2taU2gUMgqOM7dS9TWV1GTK/ExzmeEgOp8F0DQ71UMxEv3AapeLIau9/D0T/F6 zOaHk76nYzzOGheEkSBORfkzOVMiuKKZpdcGmj2AbLCc92XZb44rQZ2YDEpfRPV5n1sn D1rg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:subject:to:cc:references:from:message-id :date:user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=mMDLlM26mvl4ryqc/DF04/Gla4zjoqsvj5uvknP9EyM=; b=AnLFJiD9ntrVKwSlmK5s2QIEQA+mF9zOLyJRFCql8VUwXkJgklHdN2FYFfskVI+MZo njuxRR1S/GSrNn8XmLo5Gi7qD1fsXYKoYFlgRYzcuWDpt2cx3kzYbqglOcMiEMY4jn84 lie28J4/GBtkHUrcr8mrOELor3o33giegsBPyIhNNzC8zeMQ8Be9B4ZSRT+Qnco3SGNC bt7oNqj7wU0IcoLN6ete8hiSFaz9iB5iPVFcEFJmDF8PRvonlpl4v2BWwh20DRL+t5gO DQEOgOa58WQxC7EhCUtMQJweOtAaZE+rTeHljSDrhQ0P+FeCQH9EKoK80nfklY1FuAwW 4Mdw== X-Gm-Message-State: AOAM53241OPY+CIvIAcCMmOpAZWjlYW+XeTKnAmBh6lfjXFnurIybhGN 74z++5Supyu58B4dj3XwjDoRfjIC+Bw= X-Google-Smtp-Source: ABdhPJxREEyx7KY9kaXSepZ7zuDMG+toBVzj6WPTswT5OQoEfXmxvimSo/eIJ2oToVfc7yyevvDczQ== X-Received: by 2002:a05:6000:1547:: with SMTP id 7mr9280575wry.301.1614456093623; Sat, 27 Feb 2021 12:01:33 -0800 (PST) Received: from [192.168.0.6] ([46.251.119.176]) by smtp.googlemail.com with ESMTPSA id r20sm16611751wmd.18.2021.02.27.12.01.32 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sat, 27 Feb 2021 12:01:32 -0800 (PST) Subject: Re: bug#46761: 28.0.50; Speed up json.el encoding To: "Basil L. Contovounesios" References: <87a6rtszgk.fsf@tcd.ie> <06140794-3f40-8a35-573d-4414d2611afc@yandex.ru> <87a6rp1f64.fsf@tcd.ie> From: Dmitry Gutov Message-ID: Date: Sat, 27 Feb 2021 22:01:29 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 MIME-Version: 1.0 In-Reply-To: <87a6rp1f64.fsf@tcd.ie> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-Spam-Score: 0.1 (/) X-Debbugs-Envelope-To: 46761 Cc: 46761@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.9 (/) On 27.02.2021 21:30, Basil L. Contovounesios wrote: >> but I can't think of a use case where this would matter. > Agreed, because by the time a single with-temp-buffer becomes the > limiting factor, the encoding time for such small objects is trivially > small. I suppose someone somewhere could be encoding lots of small objects in a loop. That will likely become slower. But we can install the patch and then wait for someone to report such problem. From debbugs-submit-bounces@debbugs.gnu.org Sat Feb 27 16:09:12 2021 Received: (at 46761) by debbugs.gnu.org; 27 Feb 2021 21:09:12 +0000 Received: from localhost ([127.0.0.1]:45471 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lG6pr-0007eN-Qu for submit@debbugs.gnu.org; Sat, 27 Feb 2021 16:09:12 -0500 Received: from mail-wr1-f44.google.com ([209.85.221.44]:36456) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lG6pq-0007eB-7u for 46761@debbugs.gnu.org; Sat, 27 Feb 2021 16:09:10 -0500 Received: by mail-wr1-f44.google.com with SMTP id u14so12018774wri.3 for <46761@debbugs.gnu.org>; Sat, 27 Feb 2021 13:09:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tcd.ie; s=google21; h=from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version; bh=RjYY8dxN202gcQhCB3TXPtvOxomvl2btxIkHuKLNMsU=; b=Z5oVLo0ETAfcVq3oZWLV1z5GdHLUC9UUbgFWKsZFexM0B2PCcu1dJzMCyCN15RKSzo gwwlcNURyvOMRO0cyAYpcbjyhzFwoFEAEPJ6XBn01McuOVW+cgLyqLQDuVZVH/UheU6k VbjR7/wAHwewYaaTlj80SzO0tYvOXd751RW1MAS/12CUjmp9q6Z+v75xg7ulbvjp4erC 9icYkLv5p9gE72SZeaVfR9h2F1CLOUajXXtAhrzOQwlfDDE5W6fFAtk3IJXxfWbJeJ8h WKwz8HOWRwvXRMKmJzlVFpo5AcNk+qqHIG7i+8DHSfUI5JFG15vo7rm4cjD6vcBnoEI5 uqjg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:references:date:in-reply-to :message-id:user-agent:mime-version; bh=RjYY8dxN202gcQhCB3TXPtvOxomvl2btxIkHuKLNMsU=; b=O+b5/0Jp8wZgBWkqm6dxOPBuLsXs9zeFDwpNIWAhVEe4P/Hw0LS+oOJns1ZyZ3AI1p eH9zyFGnSVqwhWFbXdpu2DuxSDRZnGBMsXsHWf18uMN5MMLT9r0Zk1B6RU2giVfeeTay E+yqWErIhWc/8IAr/kChY5P1DPVlVfiBQ0uRNOZ0uvfx/75Yf1w7ZQDkMEcx//1iaB2c odUDD91qtvyfib2UOTim+ABgM7V6bbOuc+nYqTsyQyQae+ASmTDDR9rSSTkBQPRny/zf BXbrF49pD9s9arAoqILOUWdDbQgcuuv/HNAsi3nQLDY+EkxmzxjnlrYgAwffpynKhuYF lzIg== X-Gm-Message-State: AOAM5320asAcDPfX7W/q4QGH8xXwIuEy9rmzJh9xafsjWzPhzp1kNWl2 6L7UBN51/GoHj/6gmhsvgIwMUA== X-Google-Smtp-Source: ABdhPJyGIHJaRXi9zT8HOTVPcLOAGt5Jg6sc3SCGIYExxt/nN9ucTcFqPiNBf0rXwX8NSJnApliD8g== X-Received: by 2002:adf:8084:: with SMTP id 4mr9257867wrl.49.1614460144409; Sat, 27 Feb 2021 13:09:04 -0800 (PST) Received: from localhost ([2a02:8084:20e2:c380:d15:339e:aa10:60f1]) by smtp.gmail.com with ESMTPSA id m17sm16260559wmq.5.2021.02.27.13.09.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 27 Feb 2021 13:09:03 -0800 (PST) From: "Basil L. Contovounesios" To: Dmitry Gutov Subject: Re: bug#46761: 28.0.50; Speed up json.el encoding References: <87a6rtszgk.fsf@tcd.ie> <06140794-3f40-8a35-573d-4414d2611afc@yandex.ru> <87a6rp1f64.fsf@tcd.ie> Date: Sat, 27 Feb 2021 21:09:02 +0000 In-Reply-To: (Dmitry Gutov's message of "Sat, 27 Feb 2021 22:01:29 +0200") Message-ID: <8735xh1amp.fsf@tcd.ie> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: -0.0 (/) X-Debbugs-Envelope-To: 46761 Cc: 46761@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) Dmitry Gutov writes: > On 27.02.2021 21:30, Basil L. Contovounesios wrote: >> Agreed, because by the time a single with-temp-buffer becomes the >> limiting factor, the encoding time for such small objects is trivially >> small. > > I suppose someone somewhere could be encoding lots of small objects in a > loop. That will likely become slower. > > But we can install the patch and then wait for someone to report such problem. If only Emacs had some sort of JSON support for such performance critical applications ;). -- Basil From debbugs-submit-bounces@debbugs.gnu.org Sat Feb 27 16:10:30 2021 Received: (at 46761) by debbugs.gnu.org; 27 Feb 2021 21:10:30 +0000 Received: from localhost ([127.0.0.1]:45475 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lG6r8-0007gS-4R for submit@debbugs.gnu.org; Sat, 27 Feb 2021 16:10:30 -0500 Received: from mail-ed1-f48.google.com ([209.85.208.48]:46680) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lG6r5-0007gE-Vw for 46761@debbugs.gnu.org; Sat, 27 Feb 2021 16:10:29 -0500 Received: by mail-ed1-f48.google.com with SMTP id c23so9007550edr.13 for <46761@debbugs.gnu.org>; Sat, 27 Feb 2021 13:10:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=hd0Nx+7h+PiKGKA7j8bx/VapKR2asJ89MliHnzl2QWk=; b=jXf/eiuAsZ4hiKeJ8rblEvHnVbmxbnLGAvH5GCzaHvcPgQuBdfSVVtWRH2lpIJeiZN G9WG1I1IFepw7GSCb4CWS8BnwyNOLbDRYQk4rU/l3XjfAHF3mc8OAsjn7Uv3fwffpERq oNDacORhbu2kG8kTBeWbKMiqTWS1FvtpyOdsXWtKOr+llpo/apno9RvxoL6xhqxlaDyb DzdqI3uANvcKnJpv4o0bh88+d7dwpaRxzSSBcBNOru7eec2VUlt0wjmU2dacbgVJPIBi OD1X1Xg1XobfeFbJn32t/rJHiKTb4VKzM6kNQwK4Q6REHrjFXr5MDzTns+HVsUZE4oTf wGKg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:subject:to:cc:references:from:message-id :date:user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=hd0Nx+7h+PiKGKA7j8bx/VapKR2asJ89MliHnzl2QWk=; b=pZv3TAtX7KJeDmLtlAqF7WW2qRFuwKJS4z/O/5B0JFu7QVEV+VFr4malI5Lto7/JXI e8/P04PELN/HrkT2EH8Rtqxg3GWbUgyWaBYBFSAaQronRlEuGtrI5kBPltQtq3QZ58K7 rm2cg42f56Id3eG30+k/Y/nYw/dGtN9TG28RcT/icOVGiBNJ/Ja6PLB2YU6QlfrtLHOb Ge1KDSxrtQFifa2OPAovTnYcrX1XiHMybvSyoPCtIRXCLPCkNRr7xTnrScfsRgTanxs3 aV2EAfFBGK/nuhI1x41L1TSLUqczJCktxvAZL+Ip8AkjDaWDL7SiANHT3EyapDR46ahn uiJw== X-Gm-Message-State: AOAM530NJg8vJNHpfkIG2LTuwLR0MonGWE0dxYjnfbPPeC49y43axWFs 1qY6Z+Q1oEk55oK/JBTfEMoinWpRHSo= X-Google-Smtp-Source: ABdhPJwKua9HP5C2HjC8XMlXrrEVxRMzXALYbt+PXq0eXCvdui8m1nN2W6raZCS+QUedaXFShOtuYw== X-Received: by 2002:a05:6402:26d5:: with SMTP id x21mr9585189edd.50.1614460222360; Sat, 27 Feb 2021 13:10:22 -0800 (PST) Received: from [192.168.0.6] ([46.251.119.176]) by smtp.googlemail.com with ESMTPSA id s13sm6678992edr.86.2021.02.27.13.10.21 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sat, 27 Feb 2021 13:10:21 -0800 (PST) Subject: Re: bug#46761: 28.0.50; Speed up json.el encoding To: "Basil L. Contovounesios" References: <87a6rtszgk.fsf@tcd.ie> <06140794-3f40-8a35-573d-4414d2611afc@yandex.ru> <87a6rp1f64.fsf@tcd.ie> <8735xh1amp.fsf@tcd.ie> From: Dmitry Gutov Message-ID: <6339bf75-33cb-5b92-7986-c471a533f4c9@yandex.ru> Date: Sat, 27 Feb 2021 23:10:17 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 MIME-Version: 1.0 In-Reply-To: <8735xh1amp.fsf@tcd.ie> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-Spam-Score: 0.1 (/) X-Debbugs-Envelope-To: 46761 Cc: 46761@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.9 (/) On 27.02.2021 23:09, Basil L. Contovounesios wrote: > If only Emacs had some sort of JSON support for such performance > critical applications;). Fair enough :-) From debbugs-submit-bounces@debbugs.gnu.org Sat Feb 27 16:16:42 2021 Received: (at 46761) by debbugs.gnu.org; 27 Feb 2021 21:16:42 +0000 Received: from localhost ([127.0.0.1]:45490 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lG6x8-0007qL-C6 for submit@debbugs.gnu.org; Sat, 27 Feb 2021 16:16:42 -0500 Received: from mail-wm1-f48.google.com ([209.85.128.48]:40712) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lG6x5-0007q7-QL for 46761@debbugs.gnu.org; Sat, 27 Feb 2021 16:16:40 -0500 Received: by mail-wm1-f48.google.com with SMTP id u11so4636362wmq.5 for <46761@debbugs.gnu.org>; Sat, 27 Feb 2021 13:16:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tcd.ie; s=google21; h=from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version; bh=oY1hVbOM0x2IdjgWqHdpWWoflCPjTNe+bfIDIShDCyk=; b=GfTnN2JO3tpSA+058BKOdhbFjQ+9eJavt7dQUIjDUllknRPRTgDmusfYAbri03wwFN 6VOYi4etvkG5SiUeK9GekQgRgVo2aNuGYL6DwmcNemChowP+2JwkasdkN1F/zxRquaEo iK2+UAFIE39D+hn5O5b6W5k1H8xKbXVHzE/tCyUjqfDPChzoLWLWKs2TlkrP3aD6HD3Q 5vXbHJPj017Zpz1U12QtkayxiVNInjIFHii5GjZsGZeHr1bDeiji+f0j5EQlI61HI4x4 QNYTEo3cmCvUBCTBPrZBvdD9YRlr0zwNXx9Z8IjVE/oqTlkN9ZTpMdf81gWqhLp4nLbE msVA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:references:date:in-reply-to :message-id:user-agent:mime-version; bh=oY1hVbOM0x2IdjgWqHdpWWoflCPjTNe+bfIDIShDCyk=; b=ZfAe56cQiiAI4FCB8kxGjcK8YXPkHBLMAywDeIhZCr9xiz5VP4+KBem0BncT1q669t Vn7uBDX9zczHwQH5krKl1HyuzccNnUsdCFoGxpFBFsC8WyrzNQdzUvf7iPficwenO6+D StoMJIVHBXiAdRD2ylc2AeA+tDOAjevXZYi/5c2oWVF5WciP7Q//FPnDwVfkVu3wNIzR 7A6ahgNSzlIajxvKvodwIkF1uBddUyRFgLfwlqOQ2iMb/Tm/dLNfBWB6620G3CK/JgRA 8imzAT3cPalejE9yC3IB8EvgrNaI3qbsGLu0svGu5Et/NJDRJuhz+VTWQMk8Qvnkn9QK LxGQ== X-Gm-Message-State: AOAM531cXw4DdQ+8mtJMpCXcLuAaDb60VhvizfXTyXjhLxm31N8xloKI wXw8uKjqO+ACIua4IHeRVLwEEg== X-Google-Smtp-Source: ABdhPJyNDvggDB/kr/8+xtrNL+K7Z6DFpeQWNygilmxfvZu16jK3G+Px+SWI17gQwDjgZ3UMHEnKhA== X-Received: by 2002:a05:600c:2248:: with SMTP id a8mr8485453wmm.167.1614460594059; Sat, 27 Feb 2021 13:16:34 -0800 (PST) Received: from localhost ([2a02:8084:20e2:c380:d15:339e:aa10:60f1]) by smtp.gmail.com with ESMTPSA id z25sm530351wmi.23.2021.02.27.13.16.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 27 Feb 2021 13:16:33 -0800 (PST) From: "Basil L. Contovounesios" To: Dmitry Gutov Subject: Re: bug#46761: 28.0.50; Speed up json.el encoding References: <87a6rtszgk.fsf@tcd.ie> <06140794-3f40-8a35-573d-4414d2611afc@yandex.ru> Date: Sat, 27 Feb 2021 21:16:32 +0000 In-Reply-To: <06140794-3f40-8a35-573d-4414d2611afc@yandex.ru> (Dmitry Gutov's message of "Sat, 27 Feb 2021 20:51:05 +0200") Message-ID: <87sg5hyzwv.fsf@tcd.ie> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: -0.0 (/) X-Debbugs-Envelope-To: 46761 Cc: 46761@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) Dmitry Gutov writes: > I'm guessing there is an approximate size where structures smaller than that > size will get slower to encode because of this change (creating a temp buffer > and switching to it are not entirely free) BTW, we could avoid creating a new buffer each time, e.g. as json-encode-string did previously, but that comes with its own set of problems that I think outweigh the benefits. -- Basil From debbugs-submit-bounces@debbugs.gnu.org Sat Feb 27 16:21:25 2021 Received: (at 46761) by debbugs.gnu.org; 27 Feb 2021 21:21:25 +0000 Received: from localhost ([127.0.0.1]:45495 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lG71h-0007xa-19 for submit@debbugs.gnu.org; Sat, 27 Feb 2021 16:21:25 -0500 Received: from mail-ej1-f54.google.com ([209.85.218.54]:33674) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lG71g-0007xM-0Y for 46761@debbugs.gnu.org; Sat, 27 Feb 2021 16:21:24 -0500 Received: by mail-ej1-f54.google.com with SMTP id jt13so21037297ejb.0 for <46761@debbugs.gnu.org>; Sat, 27 Feb 2021 13:21:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=Tc1/2qmsXPAJs5R+hm91NHoYlSyrfBvrxAkXJRQ06OM=; b=oquQs4K0Ll3CBC01bKCCmbPU5kZHKLeXMGs+rjxLQ5HXsUR79lFf3WTfggEl5UyBce VEQkyIiRQHGkHxkgMEpxY22JGymrYNanteY0eJE31GlU8jgFw6voTW6dwfY52m1u6MGu uWydOZ9EQew1hXK9odsWBGuYpxaJ9kBDHyUFyBlsxkX/HVNn6ns3ZeRMs7axUXdGg351 VfywWC8J7THLHDEkWTHHANaJr3ud02TbX0oA+nVhMSwlQJ3VkwEBjTU1MA7ax6ckl7Bv wMZMxCmWoSPn3/5BveLrk93wWgG5fkknO9aiRVxfFffAjP5u0GphAXtGtpnBGrdMSwcu 77ww== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:subject:to:cc:references:from:message-id :date:user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=Tc1/2qmsXPAJs5R+hm91NHoYlSyrfBvrxAkXJRQ06OM=; b=Hs5iPjtfV+Yf44d/0VVABg2jSaVsQhIIOZP2AcDNoAEu4cAoiP5YSxcHlxb1cgmLk8 1ot9p+9eqs9GjR6gwZ/9jxiZurWg71eQFTwIi9fTjlNoTTQvgwQpxwqp9ypZX+YklCdR eqeqzZ5qrFbFO9UXBHulCD3G9hj3hdVvZbTAb9dlecvy4nQ3G2orXpvTmph+2G/rbrE0 XJNjHqAqlBl2paElbl5DgdhoriDIMQYV9wIZun4ERBS2CZugTK73IzHddnq2+kt7omq1 TAwTZKBVZz19ghGLesdu9m6Prmw5qcEhnLmVNDG2Ivg9xn8/aIU0MIB/jCan7ROfsgl4 xEDw== X-Gm-Message-State: AOAM530BEJVKG/SQZ1IMscFRZ2B5k0B+S8Okr7kL05+CMcqgn9kP3cvY uSUJEjLXt173RtXfinXOfs+JZ+5i7GI= X-Google-Smtp-Source: ABdhPJy9l0IDHZACNzDn0ZQiDvavXCyBqtotojyRJkej2C6kgjlT16pILvdhOl5Ym1JVmZda7Ygysw== X-Received: by 2002:a17:906:39d9:: with SMTP id i25mr9439754eje.226.1614460878356; Sat, 27 Feb 2021 13:21:18 -0800 (PST) Received: from [192.168.0.6] ([46.251.119.176]) by smtp.googlemail.com with ESMTPSA id e8sm310411ejm.97.2021.02.27.13.21.17 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sat, 27 Feb 2021 13:21:17 -0800 (PST) Subject: Re: bug#46761: 28.0.50; Speed up json.el encoding To: "Basil L. Contovounesios" References: <87a6rtszgk.fsf@tcd.ie> <06140794-3f40-8a35-573d-4414d2611afc@yandex.ru> <87sg5hyzwv.fsf@tcd.ie> From: Dmitry Gutov Message-ID: Date: Sat, 27 Feb 2021 23:21:15 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 MIME-Version: 1.0 In-Reply-To: <87sg5hyzwv.fsf@tcd.ie> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-Spam-Score: 0.2 (/) X-Debbugs-Envelope-To: 46761 Cc: 46761@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.8 (/) On 27.02.2021 23:16, Basil L. Contovounesios wrote: > BTW, we could avoid creating a new buffer each time, e.g. as > json-encode-string did previously, but that comes with its own set of > problems that I think outweigh the benefits. Yes, let's not try to solve this now. I just wanted to bring it up in case someone has any directly relevant use case in mind. From debbugs-submit-bounces@debbugs.gnu.org Sat Mar 06 13:37:20 2021 Received: (at control) by debbugs.gnu.org; 6 Mar 2021 18:37:20 +0000 Received: from localhost ([127.0.0.1]:38311 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lIbnk-0004pl-K3 for submit@debbugs.gnu.org; Sat, 06 Mar 2021 13:37:20 -0500 Received: from mail-wr1-f50.google.com ([209.85.221.50]:44491) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lIbng-0004pA-JR for control@debbugs.gnu.org; Sat, 06 Mar 2021 13:37:17 -0500 Received: by mail-wr1-f50.google.com with SMTP id h98so6394925wrh.11 for ; Sat, 06 Mar 2021 10:37:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tcd.ie; s=google21; h=from:to:subject:references:date:in-reply-to:message-id:user-agent :mime-version; bh=ONAm5BF6YyU7U+VkdEljZTjW/icYsRCJGz+D3DbQKpU=; b=eA+O9fIgrBAUQxsoBcl66GZSAlsV8WTdkWDPGaLgRVatVNoiibWEJ7g4qEFwR4i1NW nLLuUdKcfzVdqTobflcZ9ffLiaRC0MQFeCx1hu+U0fsrCuKo8QrAb7TPOYpEGw3520av X5duPism6gg0mphXbFq9HmOLOnbLHMW+InU1svJKpvzi/1Kopy0LM/Biel4oEAvxnBBI VigZsdFZW1tlRrU1BjHDIcfj4ZUIKBW7xG63nA2lG3stssb3kRR5OnVyQe0qXTaquuI+ aQkjQJ8IA3Yv7ixbgXFa2ZtJM3E3dJWA2o6tPJtV45HlEb8np32Ug8Xu6tpi/fGwYcNh NvDg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:references:date:in-reply-to :message-id:user-agent:mime-version; bh=ONAm5BF6YyU7U+VkdEljZTjW/icYsRCJGz+D3DbQKpU=; b=uNRftJNkHzmRIQMytbBBMb9Dxnq56oOE4VUDB4/B/7DjQKKrm/IKYrxxMm5OMAF2BZ z+QPjSYWOA/+vB1+ie9Gcskxo7x2a6PWi29npu9Rlq+u+ouM6l+jE0ZkY653+orB2DdO Y328nD3Kp7bZ6CiBKkGUNCx3jOyOQLxxiAqYiOu/66qS9LH74LHicjFYHZFvFZXI2hi0 rcO4Il+KEII0lMcXqEUtIliXY91WHUIK26dQj4NOvn/u1T85umjr8naMpx0d6+Em7kXo J3/qhQNkpt/rvltIjQzQAdh2oipyApXp/EeCTvaH/m8/2PbDNArqz+E/E2YiUk2Gl+a/ gTug== X-Gm-Message-State: AOAM531tFdGFnEWM/9tiELfoenTQoFK4Lm/MR1rNuRKmdt1O0W8IowYw jKRKk3qKWwUu9viZmsHFh8bk7A== X-Google-Smtp-Source: ABdhPJwPSM//Jv9A9QQrqR9wntypr+ln2gTMgUi9qe0EnLt8YyESQvk2jCIyiwU7C1URix23oB7+gQ== X-Received: by 2002:adf:d84d:: with SMTP id k13mr15646534wrl.164.1615055830004; Sat, 06 Mar 2021 10:37:10 -0800 (PST) Received: from localhost ([51.37.57.126]) by smtp.gmail.com with ESMTPSA id t188sm6512674wma.25.2021.03.06.10.37.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 06 Mar 2021 10:37:09 -0800 (PST) From: "Basil L. Contovounesios" To: 46761-done@debbugs.gnu.org Subject: Re: bug#46761: 28.0.50; Speed up json.el encoding References: <87a6rtszgk.fsf@tcd.ie> <87ft1kgg9r.fsf@tcd.ie> <87a6rsgcsx.fsf@tcd.ie> Date: Sat, 06 Mar 2021 18:37:08 +0000 In-Reply-To: <87a6rsgcsx.fsf@tcd.ie> (Basil L. Contovounesios's message of "Thu, 25 Feb 2021 19:36:14 +0000") Message-ID: <87im64p1rf.fsf@tcd.ie> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: -0.0 (/) X-Debbugs-Envelope-To: control X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) tags 46761 fixed close 46761 28.1 quit Now pushed and closing. Speed up json.el encoding 428339e231 2021-03-06 18:25:44 +0000 https://git.savannah.gnu.org/cgit/emacs.git/commit/?id=428339e2316a552713b265193d6648125042cc98 -- Basil From unknown Sun Jun 15 08:36:35 2025 Received: (at fakecontrol) by fakecontrolmessage; To: internal_control@debbugs.gnu.org From: Debbugs Internal Request Subject: Internal Control Message-Id: bug archived. Date: Sun, 04 Apr 2021 11:24:06 +0000 User-Agent: Fakemail v42.6.9 # This is a fake control message. # # The action: # bug archived. thanks # This fakemail brought to you by your local debbugs # administrator