On 2016-06-23 15:11, Eli Zaretskii wrote: > Instead of hypothesizing, I suggest to profile your code with > profiler.el. If indeed redisplay is taking the time, you should see > that in the profile. The profile doesn't show that, unfortunately; in fact, we spent a significant amount of time trying to understand what was taking all that time by looking at the profile, but nothing in there was taking more than 30% of the time, and even optimizing away a function that according to the profile took 28% of the time didn't yield a measurable runtime difference. Commenting out the call to set-window-buffer (or predicating it on the window not already displaying the buffer), on the other hand, does yield a 95% performance gain. set-window-buffer does not appear in the profile; redisplay_internal does appear, but it only is credited with 30% of the execution time. I wonder what might explain these results... Clément.