mirror of
https://git.savannah.gnu.org/git/emacs.git
synced 2025-01-07 15:21:46 +00:00
Tiny JSON performance improvement
Get rid of some needless uses of apply. Measuring with (benchmark-run 10 (json-read-file "test.json")) showed 1.5-2.5% reduction of execution time. * lisp/json.el (json-peek): Nix let-binding. (json-read-string): Use concat for making a string from chars. (json-read-array): Use cond and more appropriate conversion instead of blindly applying.
This commit is contained in:
parent
5bdc97d55d
commit
ab2da681b9
@ -193,8 +193,7 @@ Unlike `reverse', this keeps the property-value pairs intact."
|
||||
|
||||
(defsubst json-peek ()
|
||||
"Return the character at point."
|
||||
(let ((char (char-after (point))))
|
||||
(or char :json-eof)))
|
||||
(or (char-after (point)) :json-eof))
|
||||
|
||||
(defsubst json-pop ()
|
||||
"Advance past the character at point, returning it."
|
||||
@ -415,7 +414,7 @@ representation will be parsed correctly."
|
||||
;; Skip over the '"'
|
||||
(json-advance)
|
||||
(if characters
|
||||
(apply 'string (nreverse characters))
|
||||
(concat (nreverse characters))
|
||||
"")))
|
||||
|
||||
;; String encoding
|
||||
@ -639,7 +638,9 @@ become JSON objects."
|
||||
(signal 'json-error (list 'bleah)))))
|
||||
;; Skip over the "]"
|
||||
(json-advance)
|
||||
(apply json-array-type (nreverse elements))))
|
||||
(pcase json-array-type
|
||||
(`vector (nreverse (vconcat elements)))
|
||||
(`list (nreverse elements)))))
|
||||
|
||||
;; Array encoding
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user