You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by Emmanuel Bourg <eb...@apache.org> on 2012/03/17 09:53:36 UTC
Re: svn commit: r1301861 - /commons/proper/csv/trunk/src/main/java/org/apache/commons/csv/CSVRecord.java
IntelliJ IDEA complains about explicit boxing. Why do you change it?
Emmanuel Bourg
Le 17/03/2012 05:12, sebb@apache.org a écrit :
> Author: sebb
> Date: Sat Mar 17 04:12:16 2012
> New Revision: 1301861
>
> URL: http://svn.apache.org/viewvc?rev=1301861&view=rev
> Log:
> @Override; explicit unboxing
>
> Modified:
> commons/proper/csv/trunk/src/main/java/org/apache/commons/csv/CSVRecord.java
>
> Modified: commons/proper/csv/trunk/src/main/java/org/apache/commons/csv/CSVRecord.java
> URL: http://svn.apache.org/viewvc/commons/proper/csv/trunk/src/main/java/org/apache/commons/csv/CSVRecord.java?rev=1301861&r1=1301860&r2=1301861&view=diff
> ==============================================================================
> --- commons/proper/csv/trunk/src/main/java/org/apache/commons/csv/CSVRecord.java (original)
> +++ commons/proper/csv/trunk/src/main/java/org/apache/commons/csv/CSVRecord.java Sat Mar 17 04:12:16 2012
> @@ -63,7 +63,7 @@ public class CSVRecord implements Serial
>
> Integer index = mapping.get(name);
>
> - return index != null ? values[index] : null;
> + return index != null ? values[index.intValue()] : null;
> }
>
> public Iterator<String> iterator() {
> @@ -81,6 +81,7 @@ public class CSVRecord implements Serial
> return values.length;
> }
>
> + @Override
> public String toString() {
> return Arrays.toString(values);
> }
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
For additional commands, e-mail: dev-help@commons.apache.org
Re: svn commit: r1301861 - /commons/proper/csv/trunk/src/main/java/org/apache/commons/csv/CSVRecord.java
Posted by Emmanuel Bourg <eb...@apache.org>.
Le 17/03/2012 12:41, sebb a écrit :
> Eclipse complains about implicit boxing.
>
> But that's not why - I changed it because it makes the extra
> processing explicit.
>
> We're trying to make the code efficient, so using explicit conversions
> means we can review whether the conversion is necessary or could be
> avoided.
>
> Leaving the explicit conversion in the code shows that we did intend
> to do the conversion.
Should we code directly in bytecode to make the code even more explicit?
Will we keep using inner classes when Java 8 lamba are available to make
the code more explicit?
I tend to avoid magic syntax when it's ambiguous, but a trivial unboxing
to access an array element is really harmless. That's the perfect
example why this syntax was introduced in Java 5: to improve the
readability.
Emmanuel Bourg
Re: svn commit: r1301861 - /commons/proper/csv/trunk/src/main/java/org/apache/commons/csv/CSVRecord.java
Posted by sebb <se...@gmail.com>.
On 17 March 2012 08:53, Emmanuel Bourg <eb...@apache.org> wrote:
> IntelliJ IDEA complains about explicit boxing. Why do you change it?
Eclipse complains about implicit boxing.
But that's not why - I changed it because it makes the extra
processing explicit.
We're trying to make the code efficient, so using explicit conversions
means we can review whether the conversion is necessary or could be
avoided.
Leaving the explicit conversion in the code shows that we did intend
to do the conversion.
>
> Emmanuel Bourg
>
>
> Le 17/03/2012 05:12, sebb@apache.org a écrit :
>
>> Author: sebb
>> Date: Sat Mar 17 04:12:16 2012
>> New Revision: 1301861
>>
>> URL: http://svn.apache.org/viewvc?rev=1301861&view=rev
>> Log:
>> @Override; explicit unboxing
>>
>> Modified:
>>
>> commons/proper/csv/trunk/src/main/java/org/apache/commons/csv/CSVRecord.java
>>
>> Modified:
>> commons/proper/csv/trunk/src/main/java/org/apache/commons/csv/CSVRecord.java
>> URL:
>> http://svn.apache.org/viewvc/commons/proper/csv/trunk/src/main/java/org/apache/commons/csv/CSVRecord.java?rev=1301861&r1=1301860&r2=1301861&view=diff
>>
>> ==============================================================================
>> ---
>> commons/proper/csv/trunk/src/main/java/org/apache/commons/csv/CSVRecord.java
>> (original)
>> +++
>> commons/proper/csv/trunk/src/main/java/org/apache/commons/csv/CSVRecord.java
>> Sat Mar 17 04:12:16 2012
>> @@ -63,7 +63,7 @@ public class CSVRecord implements Serial
>>
>> Integer index = mapping.get(name);
>>
>> - return index != null ? values[index] : null;
>> + return index != null ? values[index.intValue()] : null;
>> }
>>
>> public Iterator<String> iterator() {
>> @@ -81,6 +81,7 @@ public class CSVRecord implements Serial
>> return values.length;
>> }
>>
>> + @Override
>> public String toString() {
>> return Arrays.toString(values);
>> }
>>
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
> For additional commands, e-mail: dev-help@commons.apache.org
>
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
For additional commands, e-mail: dev-help@commons.apache.org