[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] master 16fa835 40/79: Optimize JSON parser.
From: |
Jackson Ray Hamilton |
Subject: |
[elpa] master 16fa835 40/79: Optimize JSON parser. |
Date: |
Sun, 14 Jun 2015 00:05:33 +0000 |
branch: master
commit 16fa8350ad55f8031b56e85ede473544d4485da8
Author: Jackson Ray Hamilton <address@hidden>
Commit: Jackson Ray Hamilton <address@hidden>
Optimize JSON parser.
---
context-coloring.el | 44 ++++++++++++++++++++++++++--------------
test/context-coloring-test.el | 2 +-
2 files changed, 29 insertions(+), 17 deletions(-)
diff --git a/context-coloring.el b/context-coloring.el
index 4586832..753a7da 100644
--- a/context-coloring.el
+++ b/context-coloring.el
@@ -409,6 +409,7 @@ provide visually \"instant\" updates at 60 frames per
second.")
arg-string)
(funcall callback arg-string))))
+;; TODO: These seem to spiral into an infinite loop sometimes.
(defun context-coloring-elisp-parse-let-varlist (type)
(let ((varlist '())
syntax-code)
@@ -723,36 +724,47 @@ provide visually \"instant\" updates at 60 frames per
second.")
(save-excursion
(context-coloring-elisp-colorize (point-min) (point-max)))))
-(defalias 'ccecb 'context-coloring-elisp-colorize-buffer)
-
;;; Shell command scopification / colorization
(defun context-coloring-apply-tokens (tokens)
- "Process a vector of TOKENS to apply context-based coloring to
+ "Process a list of TOKENS to apply context-based coloring to
the current buffer. Tokens are 3 integers: start, end, level.
-The vector is flat, with a new token occurring after every 3rd
+The list is flat, with a new token occurring after every 3rd
element."
(with-silent-modifications
- (let ((i 0)
- (len (length tokens)))
- (while (< i len)
- (context-coloring-colorize-region
- (elt tokens i)
- (elt tokens (+ i 1))
- (elt tokens (+ i 2)))
- (setq i (+ i 3))))
+ (while tokens
+ (context-coloring-colorize-region
+ (prog1 (car tokens) (setq tokens (cdr tokens)))
+ (prog1 (car tokens) (setq tokens (cdr tokens)))
+ (prog1 (car tokens) (setq tokens (cdr tokens)))))
(context-coloring-maybe-colorize-comments-and-strings)))
(defun context-coloring-parse-array (array)
"Parse ARRAY as a flat JSON array of numbers."
- (let ((braceless (substring (context-coloring-trim array) 1 -1)))
+ (let ((braceless (substring-no-properties (context-coloring-trim array) 1
-1)))
(cond
((> (length braceless) 0)
- (vconcat
- (mapcar 'string-to-number (split-string braceless ","))))
+ (let* (;; Use a leading comma to simplify the below loop's
+ ;; delimiter-checking.
+ (chars (vconcat (concat "," braceless)))
+ (index (length chars))
+ (number 0)
+ (multiplier 1)
+ numbers)
+ (while (> index 0)
+ (setq index (1- index))
+ (cond
+ ((= (elt chars index) context-coloring-COMMA-CHAR)
+ (setq numbers (cons number numbers))
+ (setq number 0)
+ (setq multiplier 1))
+ (t
+ (setq number (+ number (* (- (elt chars index) 48) multiplier)))
+ (setq multiplier (* multiplier 10)))))
+ numbers))
(t
- (vector)))))
+ (list)))))
(defvar-local context-coloring-scopifier-process nil
"The single scopifier process that can be running.")
diff --git a/test/context-coloring-test.el b/test/context-coloring-test.el
index 5726421..a74ae6c 100644
--- a/test/context-coloring-test.el
+++ b/test/context-coloring-test.el
@@ -423,7 +423,7 @@ override it."
(context-coloring-define-dispatch
'define-dispatch-scopifier
:modes '(context-coloring-test-define-dispatch-scopifier-mode)
- :scopifier (lambda () (vector)))
+ :scopifier (lambda () (list)))
(context-coloring-test-define-dispatch-scopifier-mode)
(context-coloring-mode)
(context-coloring-colorize)))
- [elpa] master e06f1a6 27/79: Color comments and strings inside quotes., (continued)
- [elpa] master e06f1a6 27/79: Color comments and strings inside quotes., Jackson Ray Hamilton, 2015/06/13
- [elpa] master 5a8186b 34/79: Color comments and strings inside defuns., Jackson Ray Hamilton, 2015/06/13
- [elpa] master 4b25191 28/79: Refactor benchmarks. Improve benchmark reliability., Jackson Ray Hamilton, 2015/06/13
- [elpa] master f3697c0 35/79: Strings are sexps., Jackson Ray Hamilton, 2015/06/13
- [elpa] master 87893df 32/79: Support comma splicing., Jackson Ray Hamilton, 2015/06/13
- [elpa] master 7167e93 19/79: Pass let and let* tests with recursive colorizer., Jackson Ray Hamilton, 2015/06/13
- [elpa] master af4f773 33/79: Colorize comments and strings inside backquotes., Jackson Ray Hamilton, 2015/06/13
- [elpa] master acaaf39 38/79: Add file statistics to benchmarks., Jackson Ray Hamilton, 2015/06/13
- [elpa] master 8836df9 37/79: Add colorization times to logs., Jackson Ray Hamilton, 2015/06/13
- [elpa] master 5661ed0 44/79: Document `:host' and `:port' properties., Jackson Ray Hamilton, 2015/06/13
- [elpa] master 16fa835 40/79: Optimize JSON parser.,
Jackson Ray Hamilton <=
- [elpa] master 3dfd515 42/79: Messy server implementation., Jackson Ray Hamilton, 2015/06/13
- [elpa] master 872bf5f 46/79: Bump required scopifier version., Jackson Ray Hamilton, 2015/06/13
- [elpa] master 2258572 39/79: Optimize. Refactor., Jackson Ray Hamilton, 2015/06/13
- [elpa] master 59492ab 41/79: Refactor token application., Jackson Ray Hamilton, 2015/06/13
- [elpa] master 233ea1a 47/79: Kill any scopifier server before running the tests., Jackson Ray Hamilton, 2015/06/13
- [elpa] master 0079778 48/79: Set `:send-report' to nil., Jackson Ray Hamilton, 2015/06/13
- [elpa] master cacf5de 49/79: Add cond support., Jackson Ray Hamilton, 2015/06/13
- [elpa] master 8d15938 43/79: Cleaner server implementation., Jackson Ray Hamilton, 2015/06/13
- [elpa] master 89286b6 54/79: Cleanup., Jackson Ray Hamilton, 2015/06/13
- [elpa] master 5f9bd49 50/79: Add comments and strings to the cond test., Jackson Ray Hamilton, 2015/06/13