[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] master ab2da68: Tiny JSON performance improvement
From: |
Mark Oteiza |
Subject: |
[Emacs-diffs] master ab2da68: Tiny JSON performance improvement |
Date: |
Mon, 14 Aug 2017 02:01:20 -0400 (EDT) |
branch: master
commit ab2da681b904cd0c7bfac3a6f5fb3347cc591f20
Author: Mark Oteiza <address@hidden>
Commit: Mark Oteiza <address@hidden>
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.
---
lisp/json.el | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
diff --git a/lisp/json.el b/lisp/json.el
index 3def94c..627e65e 100644
--- a/lisp/json.el
+++ b/lisp/json.el
@@ -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
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Emacs-diffs] master ab2da68: Tiny JSON performance improvement,
Mark Oteiza <=