commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sebb <seb...@gmail.com>
Subject Re: svn commit: r1763958 - in /commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/jpeg: decoder/JpegDecoder.java segments/DhtSegment.java
Date Sun, 09 Oct 2016 12:02:12 GMT
On 9 October 2016 at 12:53, sebb <sebbaz@gmail.com> wrote:
> On 9 October 2016 at 12:46, Benedikt Ritter <britter@apache.org> wrote:
>> Hello,
>>
>> <sebb@apache.org> schrieb am So., 9. Okt. 2016 um 12:46 Uhr:
>>
>>> Author: sebb
>>> Date: Sun Oct  9 10:46:51 2016
>>> New Revision: 1763958
>>>
>>> URL: http://svn.apache.org/viewvc?rev=1763958&view=rev
>>> Log:
>>> Simplify code and avoid exposing mutable array unnecessarily
>>>
>>> Modified:
>>>
>>> commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/jpeg/decoder/JpegDecoder.java
>>>
>>> commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/jpeg/segments/DhtSegment.java
>>>
>>> Modified:
>>> commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/jpeg/decoder/JpegDecoder.java
>>> URL:
>>> http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/jpeg/decoder/JpegDecoder.java?rev=1763958&r1=1763957&r2=1763958&view=diff
>>>
>>> ==============================================================================
>>> ---
>>> commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/jpeg/decoder/JpegDecoder.java
>>> (original)
>>> +++
>>> commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/jpeg/decoder/JpegDecoder.java
>>> Sun Oct  9 10:46:51 2016
>>> @@ -423,13 +423,13 @@ public class JpegDecoder extends BinaryF
>>>          // "DECODE", section F.2.2.3, figure F.16, page 109 of T.81
>>>          int i = 1;
>>>          int code = is.nextBit();
>>> -        while (code > huffmanTable.getMaxCode()[i]) {
>>> +        while (code > huffmanTable.getMaxCode(i)) {
>>>              i++;
>>>              code = (code << 1) | is.nextBit();
>>>          }
>>> -        int j = huffmanTable.getValPtr()[i];
>>> -        j += code - huffmanTable.getMinCode()[i];
>>> -        return huffmanTable.getHuffVal()[j];
>>> +        int j = huffmanTable.getValPtr(i);
>>> +        j += code - huffmanTable.getMinCode(i);
>>> +        return huffmanTable.getHuffVal(j);
>>>      }
>>>
>>>      public BufferedImage decode(final ByteSource byteSource) throws
>>> IOException,
>>>
>>> Modified:
>>> commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/jpeg/segments/DhtSegment.java
>>> URL:
>>> http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/jpeg/segments/DhtSegment.java?rev=1763958&r1=1763957&r2=1763958&view=diff
>>>
>>> ==============================================================================
>>> ---
>>> commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/jpeg/segments/DhtSegment.java
>>> (original)
>>> +++
>>> commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/jpeg/segments/DhtSegment.java
>>> Sun Oct  9 10:46:51 2016
>>> @@ -32,7 +32,7 @@ public class DhtSegment extends Segment
>>>          // to avoid subtractions by one later when indexing them
>>>          public final int tableClass;
>>>          public final int destinationIdentifier;
>>> -        private final int[] bits; // 1-based
>>> +        private final int[] bits; // 1-based TODO UNUSED?
>>>          private final int[] huffVal; // 0-based
>>>
>>>          // derived properties:
>>> @@ -115,32 +115,32 @@ public class DhtSegment extends Segment
>>>
>>>          }
>>>
>>> -        public int[] getBits() {
>>> -            return bits;
>>> -        }
>>> +//        public int[] getBits() { UNUSED
>>> +//            return bits;
>>> +//        }
>>>
>>
>> if the code is unused, I think we should delete it.
>>
>
> Well yes, but if the code may be used via reflection, how can we tell?

Or in other cases, it looks as tho' the code is only partially
complete, so may be needed later.
It's not always easy to tell why the code is currently unused.

>>>
>>> -        public int[] getHuffVal() {
>>> -            return huffVal;
>>> +        public int getHuffVal(int i) {
>>> +            return huffVal[i];
>>>          }
>>>
>>> -        public int[] getHuffSize() {
>>> -            return huffSize;
>>> -        }
>>> +//        public int[] getHuffSize() { UNUSED
>>> +//            return huffSize;
>>> +//        }
>>>
>>> -        public int[] getHuffCode() {
>>> -            return huffCode;
>>> -        }
>>> +//        public int[] getHuffCode() { UNUSED
>>> +//            return huffCode;
>>> +//        }
>>>
>>> -        public int[] getMinCode() {
>>> -            return minCode;
>>> +        public int getMinCode(int i) {
>>> +            return minCode[i];
>>>          }
>>>
>>> -        public int[] getMaxCode() {
>>> -            return maxCode;
>>> +        public int getMaxCode(int i) {
>>> +            return maxCode[i];
>>>          }
>>>
>>> -        public int[] getValPtr() {
>>> -            return valPtr;
>>> +        public int getValPtr(int i) {
>>> +            return valPtr[i];
>>>          }
>>>      }
>>>
>>>
>>>
>>>

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
For additional commands, e-mail: dev-help@commons.apache.org


Mime
View raw message