Last active
August 29, 2015 13:56
-
-
Save tduehr/9279955 to your computer and use it in GitHub Desktop.
prototype of caching RubyString objects created from Java string literals
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
class RubyString { | |
//... | |
private final ObjectProxyCache<IRubyObject,RubyString> stringCache = | |
new ObjectProxyCache<Object,RubyString>(ObjectProxyCache.ReferenceType.SOFT) { | |
public IRubyObject allocateProxy(CharSequence str, RubyClass clazz) { | |
return RubyString.newString(clazz.getRuntime(), str); | |
} | |
}; | |
public RubyString cachedString(CharSequence s){ | |
return stringCache.get(s); | |
} | |
// ... | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment