Permalink
Browse files

Move memoization out to its own repository.

  • Loading branch information...
1 parent f05cf35 commit 51bc4c912b5238206d553d3dbf4b085e5f8bd18b @skeeto committed Aug 6, 2012
Showing with 4 additions and 46 deletions.
  1. +3 −0 .gitmodules
  2. +1 −0 memoize
  3. +0 −46 memoize.el
View
@@ -30,3 +30,6 @@
path = graphviz-dot-mode
url = https://github.com/ppareit/graphviz-dot-mode.git
ignore = untracked
+[submodule "memoize"]
+ path = memoize
+ url = https://github.com/skeeto/emacs-memoize.git
Submodule memoize added at a9b3a7
View
@@ -1,46 +0,0 @@
-;; -*-lexical-binding: t; -*-
-;;; memoize.el --- memoize elisp functions
-
-;; Written by Christopher Wellons <mosquitopsu@gmail.com>
-;; This program is public domain.
-
-;;; Commentary:
-
-;; Memoizing an interactive function will render that function
-;; non-interactive. It would be easy to fix this problem when it comes
-;; to non-byte-compiled functions, but recovering the interactive
-;; definition from a byte-compiled function is more complex than I
-;; care to deal with. Besides, interactive functions are always used
-;; for their side effects anyway.
-
-;; There's no way to memoize nil returns, but why would your expensive
-;; functions do all that work just to return nil? :-)
-
-;; If you wait to byte-compile the function until *after* it is
-;; memoized then the function and memoization wrapper both get
-;; compiled at once, so there's no special reason to do them
-;; separately. But there really isn't much advantage to compiling the
-;; memoization wrapper anyway.
-
-(defun memoize (func)
- "Memoize the given function. If argument is a symbol then
-install the memoized function over the original function."
- (typecase func
- (symbol
- (put func 'function-documentation
- (concat (documentation func) " (memoized)"))
- (fset func (memoize-wrap (symbol-function func)))
- func)
- (function (memoize-wrap func))))
-
-;; ID: 83bae208-da65-3e26-2ecb-4941fb310848
-(defun memoize-wrap (func)
- "Return the memoized version of FUNC."
- (let ((table (make-hash-table :test 'equal)))
- (lambda (&rest args)
- (let ((value (gethash args table)))
- (if value
- value
- (puthash args (apply func args) table))))))
-
-(provide 'memoize)

0 comments on commit 51bc4c9

Please sign in to comment.