Yonik Seeley commented on SOLR-9546:

bq. That was just one example. Check getBool()

I was responding to "unnecessary boxing".  For getBool for example, has both a 
boxed and primitive version:
The boxed version is so you can tell if a value was actually present, and the 
primitive version can be used if you provide the primitive default.
  /** Returns the Boolean value of the param, or null if not set */
  public Boolean getBool(String param) {
    String val = get(param);
    return val==null ? null : StrUtils.parseBool(val);

  /** Returns the boolean value of the param, or def if not set */
  public boolean getBool(String param, boolean def) {
    String val = get(param);
    return val==null ? def : StrUtils.parseBool(val);

> 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

To unsubscribe, e-mail: dev-unsubscr...@lucene.apache.org
For additional commands, e-mail: dev-h...@lucene.apache.org

Reply via email to