* json.el speed-ups
@ 2008-10-07 13:29 T. V. Raman
2008-10-07 16:35 ` Stefan Monnier
0 siblings, 1 reply; 3+ messages in thread
From: T. V. Raman @ 2008-10-07 13:29 UTC (permalink / raw)
To: emacs-devel
I've been using the following mods to json.el with good results,
am attaching diff output.
Change Summary:
Use forward-char in json-advance
Use skip-syntax-forward to implement skipping whitespace
diff json.el ~/sourceforge/emacs/lisp/json.el
126,127c126,130
< (forward-char n))
<
---
> (unless n (setq n 1))
> (let ((goal (+ (point) n)))
> (goto-char goal)
> (when (< (point) goal)
> (signal 'end-of-file nil))))
142c145
< (defsubst json-skip-whitespace ()
---
> (defun json-skip-whitespace ()
144c147,148
< (skip-syntax-forward " "))
---
> (while (looking-at "[\t\r\n\f\b ]")
> (goto-char (match-end 0))))
06:28:10 labrador g-client $
--
Best Regards,
--raman
Email: raman@users.sf.net
WWW: http://emacspeak.sf.net/raman/
AIM: emacspeak GTalk: tv.raman.tv@gmail.com
PGP: http://emacspeak.sf.net/raman/raman-almaden.asc
Google: tv+raman
IRC: irc://irc.freenode.net/#emacs
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: json.el speed-ups
2008-10-07 13:29 json.el speed-ups T. V. Raman
@ 2008-10-07 16:35 ` Stefan Monnier
2008-10-08 3:21 ` T. V. Raman
0 siblings, 1 reply; 3+ messages in thread
From: Stefan Monnier @ 2008-10-07 16:35 UTC (permalink / raw)
To: raman; +Cc: emacs-devel
> I've been using the following mods to json.el with good results,
> am attaching diff output.
Please use unified diffs (or context diffs).
> < (forward-char n))
> ---
>> (unless n (setq n 1))
>> (let ((goal (+ (point) n)))
>> (goto-char goal)
>> (when (< (point) goal)
>> (signal 'end-of-file nil))))
That looks OK, as long as the code doesn't catch `end-of-file' or
`end-of-buffer' explicitly elsewhere.
> 144c147,148
> < (skip-syntax-forward " "))
> ---
>> (while (looking-at "[\t\r\n\f\b ]")
>> (goto-char (match-end 0))))
Using (skip-chars-forward "\t\r\n\f\b ") would make the diff more
obviously correct. Have you checked that all those chars have the
"whitespace" syntax in the syntax-table?
Stefan
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: json.el speed-ups
2008-10-07 16:35 ` Stefan Monnier
@ 2008-10-08 3:21 ` T. V. Raman
0 siblings, 0 replies; 3+ messages in thread
From: T. V. Raman @ 2008-10-08 3:21 UTC (permalink / raw)
To: monnier; +Cc: emacs-devel, raman
Yes, the \b should be added as you suggest to be equivalent.
Eventually I think json.el should be sped up by creating a json
specific syntax table. This would help enormously in things like
parsing numbers etc; for now, json-read-number loops through each
char making up the number. As does json-read-keyword, and many
other functions.
>>>>> "Stefan" == Stefan Monnier <monnier@IRO.UMontreal.CA> writes:
>> I've been using the following mods to json.el with good
>> results, am attaching diff output.
Stefan>
Stefan> Please use unified diffs (or context diffs).
Stefan>
>> < (forward-char n))
>> ---
>>> (unless n (setq n 1)) (let ((goal (+ (point) n)))
>>> (goto-char goal) (when (< (point) goal) (signal
>>> 'end-of-file nil))))
Stefan>
Stefan> That looks OK, as long as the code doesn't catch
Stefan> `end-of-file' or `end-of-buffer' explicitly
Stefan> elsewhere.
Stefan>
>> 144c147,148 < (skip-syntax-forward " "))
>> ---
>>> (while (looking-at "[\t\r\n\f\b ]") (goto-char (match-end
>>> 0))))
Stefan>
Stefan> Using (skip-chars-forward "\t\r\n\f\b ") would make
Stefan> the diff more obviously correct. Have you checked
Stefan> that all those chars have the "whitespace" syntax in
Stefan> the syntax-table?
Stefan>
Stefan>
Stefan> Stefan
--
Best Regards,
--raman
Email: raman@users.sf.net
WWW: http://emacspeak.sf.net/raman/
AIM: emacspeak GTalk: tv.raman.tv@gmail.com
PGP: http://emacspeak.sf.net/raman/raman-almaden.asc
Google: tv+raman
IRC: irc://irc.freenode.net/#emacs
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2008-10-08 3:21 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-10-07 13:29 json.el speed-ups T. V. Raman
2008-10-07 16:35 ` Stefan Monnier
2008-10-08 3:21 ` T. V. Raman
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).