unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* Strange performance hit for insert-file-contents-literally()
@ 2009-11-27  7:58 Nordlöw
  2009-11-27  8:26 ` Nordlöw
  0 siblings, 1 reply; 5+ messages in thread
From: Nordlöw @ 2009-11-27  7:58 UTC (permalink / raw)
  To: help-gnu-emacs

I am implementing a package for doing recursive file system magic-
detect and scan/search/grep for pattern.
In this process I have stumbled across a strange performance problem;

If I want to grep for raw binary (literal) patterns, I thought that
  (benchmark-run 1 (with-temp-buffer (buffer-disable-undo) (insert-
file-contents-literally "~/pnw.tar.gz" nil)))

would given optimal performance but it turns out that
  (benchmark-run 1 (save-excursion (set-buffer (find-file-noselect "~/
pnw.tar.gz" t t))))

is about 11 times faster on my laptop PC (the first time its called of
course, the second time it reuses the open buffer so that doesn't
count)!.

As find-file-noselect() uses insert-file-contents-literally() it must
disable some stuff that find-file-literally() doesn't. The question is
what?

I would prefer no to be forced to use find-file-noselect() as this
does other unneccessary stuff I don't need.
It also reuses the buffer if its already open which is not always what
I want with compressed files for example.
My logic namely detects the file magic headers for compressed files
and then reopens them non-literally using jka-compr in order to detect
their underlying (decompressed) type like the unix program "file"
does.

Is this maybe a bug?

I am currently using Emacs CVS.

Thanks in advance for all tips,
Nordlöw


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

end of thread, other threads:[~2009-11-27 15:17 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-11-27  7:58 Strange performance hit for insert-file-contents-literally() Nordlöw
2009-11-27  8:26 ` Nordlöw
2009-11-27  9:25   ` Nordlöw
2009-11-27 15:17     ` Drew Adams
2009-11-27 15:17   ` Drew Adams

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