Skip to content

Commit

Permalink
Unreference wrapped function in _.once
Browse files Browse the repository at this point in the history
Assuming we'll never run the wrapped function again on _.once(), we can
assign null to the `func` variable, so function (and all its inherited
scopes) may be collected by GC if needed.
  • Loading branch information
subzey committed Aug 7, 2012
1 parent 2eb8d2d commit ac7f640
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion underscore.js
Original file line number Diff line number Diff line change
Expand Up @@ -623,7 +623,9 @@
return function() {
if (ran) return memo;
ran = true;
return memo = func.apply(this, arguments);
memo = func.apply(this, arguments);
func = null;
return memo;
};
};

Expand Down

0 comments on commit ac7f640

Please sign in to comment.