[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: master 979308b4ca 5/9: org-export-data: Concatenate strings in tempo
Re: master 979308b4ca 5/9: org-export-data: Concatenate strings in temporary buffer for performance
Thu, 16 Jun 2022 20:49:27 +0800
Stefan Monnier <firstname.lastname@example.org> writes:
> Eli Zaretskii [2022-06-16 04:09:44] wrote:
>> org-export-data: Concatenate strings in temporary buffer for performance
>> * lisp/org/ox.el (org-export-data): Use temporary buffer to collect
>> data instead of `mapconcat'. Using buffer puts less load on garbage
> AFAICT this just replaces `mapconcat` with a `with-temp-buffer + dolist
> + insert`, so if this makes a significant performance difference, it
> points to a performance problem in our `mapconcat`, right?
I hope that I did not get it wrong. I _believe_ that I did see an
improvement. So, you better check if it makes a difference on your side
if you revert that patch (especially with un-optimized build where the
differences should be more prominent).
AFAIK, there are several caveats with `mapconcat':
1. The way it was used in Org before the patch was
(mapconcat #function sequence "")
Here, `mapconcat' will call `concat' to generate the new string with 2N
number of arguments. Half of the arguments will be "".
2. `concat' is doing ad-hoc save/restore of text properties. IDK if it
matters in this particular case, but buffers should work more
efficiently with handling text properties (AFAIK)
3. `concat' tries to consider non-string argument adding some (probably
small) extra overheads.