emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [RFC]: replace-region-contents


From: Tassilo Horn
Subject: Re: [RFC]: replace-region-contents
Date: Wed, 06 Feb 2019 18:02:34 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux)

Eli Zaretskii <address@hidden> writes:

>> I prepared a tar.xz with a synthetic, huge, one-line JSON file
>> generated by https://next.json-generator.com and a lisp file
>> benchmarking the current against my proposed version of
>> `json-pretty-print'.
>> 
>> https://drive.google.com/open?id=1kKahq3csBVXWL-nN1-eMhgDctGWBN1AR
>
> Ouch!
>
> I guess we'd need to limit use of replace-region-contents to small
> enough JSON strings?

I wouldn't want to do that check everywhere I might want to use
replace-buffer-contents.  And the size is not really what matters.
Instead the number of differences is the crucial thing.  When I run my
version on the already formatted JSON, i.e., there are zero differences,
it is done exactly as fast as the original version.

The bottleneck is `compareseq' in lib/diffseq.h.  Maybe that could
signal if more than some maximum number of differences have already been
found, and in that case `replace-buffer-contents' would fallback to a
plain delete and insert?

Bye,
Tassilo



reply via email to

[Prev in Thread] Current Thread [Next in Thread]