commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ebo...@apache.org
Subject svn commit: r1545280 - in /commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging: common/ common/bytesource/ common/mylzw/ formats/bmp/ formats/bmp/pixelparsers/ formats/gif/ formats/ico/ formats/jpeg/ formats/jpeg/decoder/ formats/jpeg...
Date Mon, 25 Nov 2013 13:47:54 GMT
Author: ebourg
Date: Mon Nov 25 13:47:53 2013
New Revision: 1545280

URL: http://svn.apache.org/r1545280
Log:
Removed redundant local variables

Modified:
    commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/common/Compression.java
    commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/common/FastByteArrayOutputStream.java
    commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/common/PackBits.java
    commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/common/bytesource/ByteSourceFile.java
    commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/common/mylzw/MyLzwDecompressor.java
    commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/bmp/BmpImageParser.java
    commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/bmp/pixelparsers/PixelParser.java
    commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/bmp/pixelparsers/PixelParserRgb.java
    commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/gif/GifImageParser.java
    commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/ico/IcoImageParser.java
    commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/jpeg/JpegImageParser.java
    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/xmp/JpegXmpParser.java
    commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/png/ScanExpediter.java

Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/common/Compression.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/common/Compression.java?rev=1545280&r1=1545279&r2=1545280&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/common/Compression.java
(original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/common/Compression.java
Mon Nov 25 13:47:53 2013
@@ -30,29 +30,23 @@ public class Compression {
             final int expectedSize, final ByteOrder byteOrder) throws IOException {
         final InputStream is = new ByteArrayInputStream(compressed);
 
-        final MyLzwDecompressor decompressor = new MyLzwDecompressor(
-                LZWMinimumCodeSize, byteOrder);
-        final byte[] result = decompressor.decompress(is, expectedSize);
+        final MyLzwDecompressor decompressor = new MyLzwDecompressor(LZWMinimumCodeSize,
byteOrder);
 
-        return result;
+        return decompressor.decompress(is, expectedSize);
     }
 
     public byte[] decompressPackBits(final byte compressed[], final int expectedSize,
             final ByteOrder byteOrder) throws ImageReadException {
-        final byte unpacked[] = new PackBits().decompress(compressed, expectedSize);
-        return unpacked;
+        return new PackBits().decompress(compressed, expectedSize);
     }
 
     public byte[] compressLZW(final byte src[], final int LZWMinimumCodeSize,
             final ByteOrder byteOrder, final boolean earlyLimit) throws IOException
 
     {
-        final MyLzwCompressor compressor = new MyLzwCompressor(LZWMinimumCodeSize,
-                byteOrder, earlyLimit);
+        final MyLzwCompressor compressor = new MyLzwCompressor(LZWMinimumCodeSize, byteOrder,
earlyLimit);
 
-        final byte compressed[] = compressor.compress(src);
-
-        return compressed;
+        return compressor.compress(src);
     }
 
 }

Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/common/FastByteArrayOutputStream.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/common/FastByteArrayOutputStream.java?rev=1545280&r1=1545279&r2=1545280&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/common/FastByteArrayOutputStream.java
(original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/common/FastByteArrayOutputStream.java
Mon Nov 25 13:47:53 2013
@@ -47,8 +47,7 @@ public class FastByteArrayOutputStream e
             System.arraycopy(bytes, 0, result, 0, count);
             return result;
         }
-        final byte[] result = bytes;
-        return result;
+        return bytes;
     }
 
     public int getBytesWritten() {

Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/common/PackBits.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/common/PackBits.java?rev=1545280&r1=1545279&r2=1545280&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/common/PackBits.java
(original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/common/PackBits.java
Mon Nov 25 13:47:53 2013
@@ -67,9 +67,8 @@ public class PackBits {
                 throw new ImageReadException("Packbits: " + n);
             }
         }
-        final byte result[] = baos.toByteArray();
 
-        return result;
+        return baos.toByteArray();
 
     }
 

Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/common/bytesource/ByteSourceFile.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/common/bytesource/ByteSourceFile.java?rev=1545280&r1=1545279&r2=1545280&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/common/bytesource/ByteSourceFile.java
(original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/common/bytesource/ByteSourceFile.java
Mon Nov 25 13:47:53 2013
@@ -37,11 +37,7 @@ public class ByteSourceFile extends Byte
 
     @Override
     public InputStream getInputStream() throws IOException {
-        FileInputStream is = null;
-        BufferedInputStream bis = null;
-        is = new FileInputStream(file);
-        bis = new BufferedInputStream(is);
-        return bis;
+        return new BufferedInputStream(new FileInputStream(file));
     }
 
     @Override

Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/common/mylzw/MyLzwDecompressor.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/common/mylzw/MyLzwDecompressor.java?rev=1545280&r1=1545279&r2=1545280&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/common/mylzw/MyLzwDecompressor.java
(original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/common/mylzw/MyLzwDecompressor.java
Mon Nov 25 13:47:53 2013
@@ -183,9 +183,7 @@ public final class MyLzwDecompressor {
             }
         } // end of while loop
 
-        final byte result[] = baos.toByteArray();
-
-        return result;
+        return baos.toByteArray();
     }
 
     private void checkCodeSize() {

Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/bmp/BmpImageParser.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/bmp/BmpImageParser.java?rev=1545280&r1=1545279&r2=1545280&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/bmp/BmpImageParser.java
(original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/bmp/BmpImageParser.java
Mon Nov 25 13:47:53 2013
@@ -657,13 +657,11 @@ public class BmpImageParser extends Imag
         final int colorType = ImageInfo.COLOR_TYPE_RGB;
         final String compressionAlgorithm = ImageInfo.COMPRESSION_ALGORITHM_RLE;
 
-        final ImageInfo result = new ImageInfo(formatDetails, bitsPerPixel, comments,
+        return new ImageInfo(formatDetails, bitsPerPixel, comments,
                 format, name, height, mimeType, numberOfImages,
                 physicalHeightDpi, physicalHeightInch, physicalWidthDpi,
                 physicalWidthInch, width, isProgressive, isTransparent,
                 usesPalette, colorType, compressionAlgorithm);
-
-        return result;
     }
 
     @Override
@@ -788,7 +786,7 @@ public class BmpImageParser extends Imag
         final SimplePalette palette = new PaletteFactory().makeExactRgbPaletteSimple(
                 src, 256);
 
-        BmpWriter writer = null;
+        BmpWriter writer;
         if (palette == null) {
             writer = new BmpWriterRgb();
         } else {

Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/bmp/pixelparsers/PixelParser.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/bmp/pixelparsers/PixelParser.java?rev=1545280&r1=1545279&r2=1545280&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/bmp/pixelparsers/PixelParser.java
(original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/bmp/pixelparsers/PixelParser.java
Mon Nov 25 13:47:53 2013
@@ -50,8 +50,10 @@ public abstract class PixelParser {
         final int red = 0xff & colorTable[index + 2];
         final int alpha = 0xff;
 
-        final int rgb = (alpha << 24) | (red << 16) | (green << 8) | (blue
<< 0);
-        return rgb;
+        return (alpha << 24)
+                | (red << 16)
+                | (green << 8)
+                | (blue << 0);
     }
 
 }

Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/bmp/pixelparsers/PixelParserRgb.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/bmp/pixelparsers/PixelParserRgb.java?rev=1545280&r1=1545279&r2=1545280&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/bmp/pixelparsers/PixelParserRgb.java
(original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/bmp/pixelparsers/PixelParserRgb.java
Mon Nov 25 13:47:53 2013
@@ -54,9 +54,7 @@ public class PixelParserRgb extends Pixe
             cached_byte = 0xff & (cached_byte << bhi.bitsPerPixel);
             cached_bit_count -= bhi.bitsPerPixel;
 
-            final int rgb = getColorTableRGB(sample);
-
-            return rgb;
+            return getColorTableRGB(sample);
         } else if (bhi.bitsPerPixel == 8) { // always grayscale?
             final int sample = 0xff & imageData[bytecount + 0];
 

Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/gif/GifImageParser.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/gif/GifImageParser.java?rev=1545280&r1=1545279&r2=1545280&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/gif/GifImageParser.java
(original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/gif/GifImageParser.java
Mon Nov 25 13:47:53 2013
@@ -210,10 +210,7 @@ public class GifImageParser extends Imag
     private byte[] readSubBlock(final InputStream is) throws IOException {
         final int block_size = 0xff & readByte("block_size", is, "GIF: corrupt block");
 
-        final byte bytes[] = readBytes("block", is, block_size,
-                "GIF: corrupt block");
-
-        return bytes;
+        return readBytes("block", is, block_size, "GIF: corrupt block");
     }
 
     protected GenericGifBlock readGenericGIFBlock(final InputStream is, final int code)
@@ -408,12 +405,10 @@ public class GifImageParser extends Imag
             readGenericGIFBlock(is, -1);
         }
 
-        final ImageDescriptor result = new ImageDescriptor(blockCode,
+        return new ImageDescriptor(blockCode,
                 ImageLeftPosition, ImageTopPosition, imageWidth, imageHeight,
                 PackedFields, LocalColorTableFlag, InterlaceFlag, SortFlag,
                 SizeofLocalColorTable, LocalColorTable, imageData);
-
-        return result;
     }
 
     private int simple_pow(final int base, final int power) {
@@ -433,15 +428,11 @@ public class GifImageParser extends Imag
     private byte[] readColorTable(final InputStream is, final int ct_size) throws IOException
{
         final int actual_size = convertColorTableSize(ct_size);
 
-        final byte bytes[] = readBytes("block", is, actual_size,
-                "GIF: corrupt Color Table");
-
-        return bytes;
+        return readBytes("block", is, actual_size, "GIF: corrupt Color Table");
     }
 
-    private GifBlock findBlock(final List<GifBlock> v, final int code) {
-        for (int i = 0; i < v.size(); i++) {
-            final GifBlock gifBlock = v.get(i);
+    private GifBlock findBlock(final List<GifBlock> blocks, final int code) {
+        for (GifBlock gifBlock : blocks) {
             if (gifBlock.blockCode == code) {
                 return gifBlock;
             }
@@ -530,12 +521,11 @@ public class GifImageParser extends Imag
         return null;
     }
 
-    private List<String> getComments(final List<GifBlock> v) throws IOException
{
+    private List<String> getComments(final List<GifBlock> blocks) throws IOException
{
         final List<String> result = new ArrayList<String>();
         final int code = 0x21fe;
 
-        for (int i = 0; i < v.size(); i++) {
-            final GifBlock block = v.get(i);
+        for (GifBlock block : blocks) {
             if (block.blockCode == code) {
                 final byte bytes[] = ((GenericGifBlock) block).appendSubBlocks();
                 result.add(new String(bytes, "US-ASCII"));
@@ -601,13 +591,11 @@ public class GifImageParser extends Imag
         final int colorType = ImageInfo.COLOR_TYPE_RGB;
         final String compressionAlgorithm = ImageInfo.COMPRESSION_ALGORITHM_LZW;
 
-        final ImageInfo result = new ImageInfo(formatDetails, bitsPerPixel, comments,
+        return new ImageInfo(formatDetails, bitsPerPixel, comments,
                 format, formatName, height, mimeType, numberOfImages,
                 physicalHeightDpi, physicalHeightInch, physicalWidthDpi,
                 physicalWidthInch, width, isProgressive, isTransparent,
                 usesPalette, colorType, compressionAlgorithm);
-
-        return result;
     }
 
     @Override
@@ -1059,8 +1047,7 @@ public class GifImageParser extends Imag
             final List<GifBlock> blocks = readBlocks(ghi, is, true, formatCompliance);
 
             final List<String> result = new ArrayList<String>();
-            for (int i = 0; i < blocks.size(); i++) {
-                final GifBlock block = blocks.get(i);
+            for (GifBlock block : blocks) {
                 if (block.blockCode != XMP_COMPLETE_CODE) {
                     continue;
                 }

Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/ico/IcoImageParser.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/ico/IcoImageParser.java?rev=1545280&r1=1545279&r2=1545280&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/ico/IcoImageParser.java
(original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/ico/IcoImageParser.java
Mon Nov 25 13:47:53 2013
@@ -536,8 +536,7 @@ public class IcoImageParser extends Imag
         final ImageFormat imageFormat = Imaging.guessFormat(iconData);
         if (imageFormat.equals(ImageFormats.PNG)) {
             final BufferedImage bufferedImage = Imaging.getBufferedImage(iconData);
-            final PNGIconData pngIconData = new PNGIconData(fIconInfo, bufferedImage);
-            return pngIconData;
+            return new PNGIconData(fIconInfo, bufferedImage);
         }
         return readBitmapIconData(iconData, fIconInfo);
     }

Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/jpeg/JpegImageParser.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/jpeg/JpegImageParser.java?rev=1545280&r1=1545279&r2=1545280&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/jpeg/JpegImageParser.java
(original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/jpeg/JpegImageParser.java
Mon Nov 25 13:47:53 2013
@@ -322,9 +322,7 @@ public class JpegImageParser extends Ima
             return null;
         }
 
-        final JpegImageMetadata result = new JpegImageMetadata(photoshop, exif);
-
-        return result;
+        return new JpegImageMetadata(photoshop, exif);
     }
 
     public static boolean isExifAPP1Segment(final GenericSegment segment) {
@@ -954,13 +952,11 @@ public class JpegImageParser extends Ima
 
         final String compressionAlgorithm = ImageInfo.COMPRESSION_ALGORITHM_JPEG;
 
-        final ImageInfo result = new ImageInfo(FormatDetails, BitsPerPixel, Comments,
+        return new ImageInfo(FormatDetails, BitsPerPixel, Comments,
                 Format, FormatName, Height, MimeType, NumberOfImages,
                 PhysicalHeightDpi, PhysicalHeightInch, PhysicalWidthDpi,
                 PhysicalWidthInch, Width, isProgressive, isTransparent,
                 usesPalette, colorType, compressionAlgorithm);
-
-        return result;
     }
 
     // public ImageInfo getImageInfo(ByteSource byteSource, Map params)

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=1545280&r1=1545279&r2=1545280&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
Mon Nov 25 13:47:53 2013
@@ -427,8 +427,7 @@ public class JpegDecoder extends BinaryF
         }
         int j = huffmanTable.getValPtr()[i];
         j += code - huffmanTable.getMinCode()[i];
-        final int value = huffmanTable.getHuffVal()[j];
-        return value;
+        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/xmp/JpegXmpParser.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/jpeg/xmp/JpegXmpParser.java?rev=1545280&r1=1545279&r2=1545280&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/jpeg/xmp/JpegXmpParser.java
(original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/jpeg/xmp/JpegXmpParser.java
Mon Nov 25 13:47:53 2013
@@ -43,9 +43,7 @@ public class JpegXmpParser extends Binar
 
         try {
             // segment data is UTF-8 encoded xml.
-            final String xml = new String(segmentData, index, segmentData.length
-                    - index, "utf-8");
-            return xml;
+            return new String(segmentData, index, segmentData.length - index, "utf-8");
         } catch (final UnsupportedEncodingException e) {
             throw new ImageReadException("Invalid JPEG XMP Segment.", e);
         }

Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/png/ScanExpediter.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/png/ScanExpediter.java?rev=1545280&r1=1545279&r2=1545280&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/png/ScanExpediter.java
(original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/png/ScanExpediter.java
Mon Nov 25 13:47:53 2013
@@ -68,10 +68,10 @@ public abstract class ScanExpediter exte
     }
 
     protected final int getPixelARGB(final int alpha, final int red, final int green, final
int blue) {
-        final int rgb = ((0xff & alpha) << 24) | ((0xff & red) << 16)
-                | ((0xff & green) << 8) | ((0xff & blue) << 0);
-
-        return rgb;
+        return ((0xff & alpha) << 24)
+             | ((0xff & red)   << 16)
+             | ((0xff & green) << 8)
+             | ((0xff & blue)  << 0);
     }
 
     protected final int getPixelRGB(final int red, final int green, final int blue) {



Mime
View raw message