[ 
https://issues.apache.org/jira/browse/OAK-445?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13496951#comment-13496951
 ] 

Thomas Mueller commented on OAK-445:
------------------------------------

SVN isn't working currently it seems but the code is basically

{code}
// must be a power of 2
static final int STRING_CACHE_SIZE = 1024;        
static final String[] STRING_CACHE = new String[STRING_CACHE_SIZE];

static String getCachedString(String s) {
    int index = s.hashCode() & (STRING_CACHE_SIZE - 1);
    String cached = STRING_CACHE[index];
    if (s.equals(cached)) {
        return cached;
    }
    STRING_CACHE[index] = s;
    return s;
}
{code}
                
> Allow JSON strings to be reclaimed after they've been parsed
> ------------------------------------------------------------
>
>                 Key: OAK-445
>                 URL: https://issues.apache.org/jira/browse/OAK-445
>             Project: Jackrabbit Oak
>          Issue Type: Improvement
>          Components: core
>            Reporter: Jukka Zitting
>            Assignee: Jukka Zitting
>            Priority: Minor
>
> Currently the JsopTokenizer uses String.substring() when returning various 
> tokens. This can be a bit troublesome as the returned String instances often 
> keep a reference to the full underlying JSON string, which prevents that one 
> from being reclaimed.
> It would also be nice if the tokenizer automatically detected common tokens 
> like "jcr:primaryType" or "nt:unstructured" and use flyweight instances to 
> avoid too many duplicate copies of such strings.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

Reply via email to