emacs-devel
[Top][All Lists]
Advanced

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

Re: Move sha1 to C?


From: Leo
Subject: Re: Move sha1 to C?
Date: Tue, 24 May 2011 01:38:35 +0800
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.3.50 (Mac OS X 10.6.7)

On 2011-05-23 15:21 +0800, Eli Zaretskii wrote:
> Note that gnulib's sha1.c uses malloc, which is not safe in Emacs.
> So either make sure sha1_stream is never ever called by Emacs, or use
> xmalloc instead.

For the record, it seems there is no need to use sha1_stream:

(defun sha1-file (file)
  (with-temp-buffer
    (set-buffer-multibyte nil)
    (insert-file-contents file)
    (sha1 (current-buffer))))

(benchmark-run 1 (sha1-file "Path-to-a-700M-file"))
(9.66299 1 0.11788399999999999)

(benchmark-run 1 (shell-command-to-string "shasum Path-to-a-700M-file"))
(5.64725 0 0.0)

Leo



reply via email to

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