unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* with-output-to-temp-buffer
@ 2006-06-01 22:53 Drew Adams
  2006-06-02  0:17 ` with-output-to-temp-buffer Thien-Thi Nguyen
  2006-06-02 22:07 ` with-output-to-temp-buffer Kevin Rodgers
  0 siblings, 2 replies; 4+ messages in thread
From: Drew Adams @ 2006-06-01 22:53 UTC (permalink / raw)


I had this code:

  (set-buffer (get-buffer-create "foo"))
  (let (...) ...)
  (select-frame (make-frame ...))

I changed it to this code:

  (with-output-to-temp-buffer "foo" ...)
  (let ((temp-buffer-setup-hook nil)
        (temp-buffer-show-functions nil)
        ...)
    ...)
  (select-window (get-buffer-window "foo" 'visible))
  (modify-frame-parameters (selected-frame) ...)

The rest of the code (i.e. "...") is identical. The latter code runs about
twice as fast (clock time)! I don't use any print functions inside the
with-* - I use only `insert', so I wouldn't think that with-* would be of
any special benefit here.

I don't understand this. A glance at the C code makes me think that
with-output-to-temp-buffer would only do more, not less, stuff.

(Thinking that the difference might be make-frame vs
modify-frame-parameters, I tried using modify-frame-* for the first code
too, but that made no difference. I guess it must be with-* that speeds
things up.)

Is this to be expected? If so, should something be said about this in the
doc - for example, say something about what with-output-* does, and mention
that it might be faster than creating and setting a buffer?

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: with-output-to-temp-buffer
  2006-06-01 22:53 with-output-to-temp-buffer Drew Adams
@ 2006-06-02  0:17 ` Thien-Thi Nguyen
  2006-06-02  0:29   ` with-output-to-temp-buffer Drew Adams
  2006-06-02 22:07 ` with-output-to-temp-buffer Kevin Rodgers
  1 sibling, 1 reply; 4+ messages in thread
From: Thien-Thi Nguyen @ 2006-06-02  0:17 UTC (permalink / raw)
  Cc: Emacs-Devel

"Drew Adams" <drew.adams@oracle.com> writes:

> should something be said about this in the doc - for example,
> say something about what with-output-* does, and mention that it
> might be faster than creating and setting a buffer?

i am against adding performace-related documentation.  usually
such info is implementation-specific (prone to eventual bit-rot).
emacswiki is a better place for this kind of stuff, IMHO -- the
expectation that info there can/will-be changed is much higher.

thi

^ permalink raw reply	[flat|nested] 4+ messages in thread

* RE: with-output-to-temp-buffer
  2006-06-02  0:17 ` with-output-to-temp-buffer Thien-Thi Nguyen
@ 2006-06-02  0:29   ` Drew Adams
  0 siblings, 0 replies; 4+ messages in thread
From: Drew Adams @ 2006-06-02  0:29 UTC (permalink / raw)


    > should something be said about this in the doc - for example,
    > say something about what with-output-* does, and mention that it
    > might be faster than creating and setting a buffer?

    i am against adding performace-related documentation.  usually
    such info is implementation-specific (prone to eventual bit-rot).
    emacswiki is a better place for this kind of stuff, IMHO -- the
    expectation that info there can/will-be changed is much higher.

I actually agree, and you stated the reasons well.

In this case, it's not clear to me whether this is just a matter of
implementation or whether there might be some difference in functionality
that I'm not aware of.

If the latter, then it would be good to add some more info about what
with-output-to-temp-buffer does, to make this difference clear.

If the former, then, yes, implementation concerns should not be documented.
I'd still be curious about what is going on, however.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: with-output-to-temp-buffer
  2006-06-01 22:53 with-output-to-temp-buffer Drew Adams
  2006-06-02  0:17 ` with-output-to-temp-buffer Thien-Thi Nguyen
@ 2006-06-02 22:07 ` Kevin Rodgers
  1 sibling, 0 replies; 4+ messages in thread
From: Kevin Rodgers @ 2006-06-02 22:07 UTC (permalink / raw)


Drew Adams wrote:
> I had this code:
> 
>   (set-buffer (get-buffer-create "foo"))
>   (let (...) ...)
>   (select-frame (make-frame ...))
> 
> I changed it to this code:
> 
>   (with-output-to-temp-buffer "foo" ...)
>   (let ((temp-buffer-setup-hook nil)
>         (temp-buffer-show-functions nil)
>         ...)
>     ...)
>   (select-window (get-buffer-window "foo" 'visible))
>   (modify-frame-parameters (selected-frame) ...)
> 
> The rest of the code (i.e. "...") is identical. The latter code runs about
> twice as fast (clock time)! I don't use any print functions inside the
> with-* - I use only `insert', so I wouldn't think that with-* would be of
> any special benefit here.
> 
> I don't understand this. A glance at the C code makes me think that
> with-output-to-temp-buffer would only do more, not less, stuff.

How do with-current-buffer and with-temp-buffer perform compared to the
original version and the with-output-to-temp-buffer?

> (Thinking that the difference might be make-frame vs
> modify-frame-parameters, I tried using modify-frame-* for the first code
> too, but that made no difference. I guess it must be with-* that speeds
> things up.)

Hmmm...

-- 
Kevin

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2006-06-02 22:07 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-06-01 22:53 with-output-to-temp-buffer Drew Adams
2006-06-02  0:17 ` with-output-to-temp-buffer Thien-Thi Nguyen
2006-06-02  0:29   ` with-output-to-temp-buffer Drew Adams
2006-06-02 22:07 ` with-output-to-temp-buffer Kevin Rodgers

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).