# HG changeset patch # User Richard M. Stallman # Date 826307040 0 # Node ID 7d2e0f0d9bf71c85ccb5edfb69b5aabc5a51119e # Parent 70553c5459767b8a57288bb4a6019e2ab643356e (profile-convert-byte-code): New function. (profile-a-function): Use profile-convert-byte-code. diff -r 70553c545976 -r 7d2e0f0d9bf7 lisp/emacs-lisp/profile.el --- a/lisp/emacs-lisp/profile.el Fri Mar 08 17:43:20 1996 +0000 +++ b/lisp/emacs-lisp/profile.el Fri Mar 08 17:44:00 1996 +0000 @@ -218,9 +218,27 @@ (setcdr accum (- (cdr accum) profile-million))) ))) +(defun profile-convert-byte-code (function) + (let ((defn (symbol-function function))) + (if (byte-code-function-p defn) + ;; It is a compiled code object. + (let* ((contents (append defn nil)) + (body + (list (list 'byte-code (nth 1 contents) + (nth 2 contents) (nth 3 contents))))) + (if (nthcdr 5 contents) + (setq body (cons (list 'interactive (nth 5 contents)) body))) + (if (nth 4 contents) + ;; Use `documentation' here, to get the actual string, + ;; in case the compiled function has a reference + ;; to the .elc file. + (setq body (cons (documentation function) body))) + (fset function (cons 'lambda (cons (car contents) body))))))) + (defun profile-a-function (fun) "Profile the function FUN." (interactive "aFunction to profile: ") + (profile-convert-byte-code fun) (let ((def (symbol-function fun)) (funlen (length (symbol-name fun)))) (if (eq (car def) 'lambda) nil (error "To profile: %s must be a user-defined function" fun))