On Aug 22, 2013, at 9:12 AM, Gary Gregory wrote:

> On Thu, Aug 22, 2013 at 12:08 PM, Ralph Goers <[email protected]> 
> wrote:
> Why?
> 
> Because then the reader knows it is being done on purpose. I've fixed some 
> code today where it looks like unboxing and boxing happened back and forth 
> wastefully. For example, a class was using an Integer instead of an int and 
> conversions took place back and forth. In another case, a string was parsed 
> to an Integer only to be immediately unboxed; same for another call site but 
> for a Long, and so on.

Yes, I saw those and didn't question them.  Autoboxing was added to the 
language for a reason. The use below seems like a perfectly valid use of it. 
Furthermore, I wouldn't be surprised if the compiler is smart enough to realize 
that boxing and unboxing is going on and optimizes it away, but in those cases 
I have no problem in correcting the code.

Ralph

> 
> Gary
> 
> On Aug 22, 2013, at 9:06 AM, [email protected] wrote:
> 
> > Author: ggregory
> > Date: Thu Aug 22 16:06:08 2013
> > New Revision: 1516496
> >
> > URL: http://svn.apache.org/r1516496
> > Log:
> > Make boxing and unboxing explicit.
> >
> > Modified:
> >    
> > logging/log4j/log4j2/trunk/core/src/main/java/org/apache/logging/log4j/core/appender/rewrite/PropertiesRewritePolicy.java
> >
> > Modified: 
> > logging/log4j/log4j2/trunk/core/src/main/java/org/apache/logging/log4j/core/appender/rewrite/PropertiesRewritePolicy.java
> > URL: 
> > http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/core/src/main/java/org/apache/logging/log4j/core/appender/rewrite/PropertiesRewritePolicy.java?rev=1516496&r1=1516495&r2=1516496&view=diff
> > ==============================================================================
> > --- 
> > logging/log4j/log4j2/trunk/core/src/main/java/org/apache/logging/log4j/core/appender/rewrite/PropertiesRewritePolicy.java
> >  (original)
> > +++ 
> > logging/log4j/log4j2/trunk/core/src/main/java/org/apache/logging/log4j/core/appender/rewrite/PropertiesRewritePolicy.java
> >  Thu Aug 22 16:06:08 2013
> > @@ -49,9 +49,9 @@ public final class PropertiesRewritePoli
> >     private PropertiesRewritePolicy(final Configuration config, final 
> > List<Property> props) {
> >         this.config = config;
> >         this.properties = new HashMap<Property, Boolean>(props.size());
> > -        for (final Property prop : props) {
> > -            final boolean interpolate = prop.getValue().contains("${");
> > -            properties.put(prop, interpolate);
> > +        for (final Property property : props) {
> > +            final Boolean interpolate = 
> > Boolean.valueOf(property.getValue().contains("${"));
> > +            properties.put(property, interpolate);
> >         }
> >     }
> >
> > @@ -66,7 +66,7 @@ public final class PropertiesRewritePoli
> >         final Map<String, String> props = new HashMap<String, 
> > String>(source.getContextMap());
> >         for (final Map.Entry<Property, Boolean> entry : 
> > properties.entrySet()) {
> >             final Property prop = entry.getKey();
> > -            props.put(prop.getName(), entry.getValue() ?
> > +            props.put(prop.getName(), entry.getValue().booleanValue() ?
> >                 config.getStrSubstitutor().replace(prop.getValue()) : 
> > prop.getValue());
> >         }
> >
> >
> >
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [email protected]
> For additional commands, e-mail: [email protected]
> 
> 
> 
> 
> -- 
> E-Mail: [email protected] | [email protected] 
> Java Persistence with Hibernate, Second Edition
> JUnit in Action, Second Edition
> Spring Batch in Action
> Blog: http://garygregory.wordpress.com 
> Home: http://garygregory.com/
> Tweet! http://twitter.com/GaryGregory

Reply via email to