Created
November 30, 2010 03:23
-
-
Save matthewd/721090 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/kernel/common/sprinter.rb b/kernel/common/sprinter.rb | |
index 8a135db..40f7c51 100644 | |
--- a/kernel/common/sprinter.rb | |
+++ b/kernel/common/sprinter.rb | |
@@ -2,17 +2,15 @@ module Rubinius | |
class Sprinter | |
class << self | |
def get(format) | |
- @cache ||= {} | |
- | |
- # An alternative to the below would be to have the Builder | |
- # ignore the taint of the format, and instead have sprintf check | |
- # the format upon invocation, and taint the result there. | |
- if format.tainted? | |
- new(format) | |
- else | |
- @cache[format] || | |
- (@cache[format] = new(format)) | |
+ if t = format.data.instance_variable_get(:@cached_sprinter) | |
+ return t[1] if t[0] == format | |
end | |
+ | |
+ sprinter = new(format) | |
+ | |
+ format.data.instance_variable_set(:@cached_sprinter, Tuple[format.dup, sprinter]) | |
+ | |
+ sprinter | |
end | |
end | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment