[
https://issues.apache.org/jira/browse/SOLR-9546?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15511103#comment-15511103
]
Yonik Seeley commented on SOLR-9546:
------------------------------------
Hmmm, that's weird... the original methods did use primitives.
Looking at the current class, there *is* still the original version:
{code}
/** Returns the long value of the param, or def if not set */
public long getLong(String param, long def) {
String val = get(param);
try {
return val == null ? def : Long.parseLong(val);
} catch (Exception ex) {
throw new SolrException(SolrException.ErrorCode.BAD_REQUEST,
ex.getMessage(), ex);
}
}
{code}
But it looks like the version you reference was added more recently as part of
SOLR-6485
Anyway, I searched for usages, and that version is only used once (as part of
the issue above it looks like)
> There is a lot of unnecessary boxing/unboxing going on in {{SolrParams}} class
> ------------------------------------------------------------------------------
>
> Key: SOLR-9546
> URL: https://issues.apache.org/jira/browse/SOLR-9546
> Project: Solr
> Issue Type: Improvement
> Security Level: Public(Default Security Level. Issues are Public)
> Reporter: Pushkar Raste
> Priority: Minor
>
> Here is an excerpt
> {code}
> public Long getLong(String param, Long def) {
> String val = get(param);
> try {
> return val== null ? def : Long.parseLong(val);
> }
> catch( Exception ex ) {
> throw new SolrException( SolrException.ErrorCode.BAD_REQUEST,
> ex.getMessage(), ex );
> }
> }
> {code}
> {{Long.parseLong()}} returns a primitive type but since method expect to
> return a {{Long}}, it needs to be wrapped. There are many more method like
> that. We might be creating a lot of unnecessary objects here.
> I am not sure if JVM catches upto it and somehow optimizes it if these
> methods are called enough times (or may be compiler does some modifications
> at compile time)
> Let me know if I am thinking of some premature optimization
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]