Browse Source

Minor cleanup tweaks

af/merge-core
JimBobSquarePants 9 years ago
parent
commit
d2f6a8534f
  1. 8
      src/ImageSharp/Formats/Jpeg/GolangPort/Components/Decoder/Bits.cs
  2. 11
      src/ImageSharp/Formats/Jpeg/GolangPort/Components/Decoder/Bytes.cs

8
src/ImageSharp/Formats/Jpeg/GolangPort/Components/Decoder/Bits.cs

@ -92,8 +92,7 @@ namespace SixLabors.ImageSharp.Formats.Jpeg.GolangPort.Components.Decoder
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public int ReceiveExtend(int t, ref InputProcessor inputProcessor) public int ReceiveExtend(int t, ref InputProcessor inputProcessor)
{ {
int x; OrigDecoderErrorCode errorCode = this.ReceiveExtendUnsafe(t, ref inputProcessor, out int x);
OrigDecoderErrorCode errorCode = this.ReceiveExtendUnsafe(t, ref inputProcessor, out x);
errorCode.EnsureNoError(); errorCode.EnsureNoError();
return x; return x;
} }
@ -120,7 +119,7 @@ namespace SixLabors.ImageSharp.Formats.Jpeg.GolangPort.Components.Decoder
this.UnreadBits -= t; this.UnreadBits -= t;
this.Mask >>= t; this.Mask >>= t;
int s = 1 << t; int s = 1 << t;
x = (int)((this.Accumulator >> this.UnreadBits) & (s - 1)); x = (this.Accumulator >> this.UnreadBits) & (s - 1);
if (x < (s >> 1)) if (x < (s >> 1))
{ {
@ -132,8 +131,7 @@ namespace SixLabors.ImageSharp.Formats.Jpeg.GolangPort.Components.Decoder
private OrigDecoderErrorCode EnsureBitsStepImpl(ref InputProcessor inputProcessor) private OrigDecoderErrorCode EnsureBitsStepImpl(ref InputProcessor inputProcessor)
{ {
int c; OrigDecoderErrorCode errorCode = inputProcessor.Bytes.ReadByteStuffedByteUnsafe(inputProcessor.InputStream, out int c);
OrigDecoderErrorCode errorCode = inputProcessor.Bytes.ReadByteStuffedByteUnsafe(inputProcessor.InputStream, out c);
if (errorCode != OrigDecoderErrorCode.NoError) if (errorCode != OrigDecoderErrorCode.NoError)
{ {

11
src/ImageSharp/Formats/Jpeg/GolangPort/Components/Decoder/Bytes.cs

@ -59,10 +59,10 @@ namespace SixLabors.ImageSharp.Formats.Jpeg.GolangPort.Components.Decoder
public static Bytes Create() public static Bytes Create()
{ {
return new Bytes return new Bytes
{ {
Buffer = BytePool.Rent(BufferSize), Buffer = BytePool.Rent(BufferSize),
BufferAsInt = IntPool.Rent(BufferSize) BufferAsInt = IntPool.Rent(BufferSize)
}; };
} }
/// <summary> /// <summary>
@ -148,8 +148,7 @@ namespace SixLabors.ImageSharp.Formats.Jpeg.GolangPort.Components.Decoder
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public byte ReadByte(Stream inputStream) public byte ReadByte(Stream inputStream)
{ {
byte result; OrigDecoderErrorCode errorCode = this.ReadByteUnsafe(inputStream, out byte result);
OrigDecoderErrorCode errorCode = this.ReadByteUnsafe(inputStream, out result);
errorCode.EnsureNoError(); errorCode.EnsureNoError();
return result; return result;
} }

Loading…
Cancel
Save