Skip to content

Commit

Permalink
renaming is hard
Browse files Browse the repository at this point in the history
  • Loading branch information
antonfirsov committed Aug 18, 2017
1 parent 51b430b commit 493deda
Show file tree
Hide file tree
Showing 15 changed files with 179 additions and 179 deletions.
36 changes: 18 additions & 18 deletions src/ImageSharp/Formats/Jpeg/GolangPort/Components/Decoder/Bits.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,25 +40,25 @@ internal struct Bits
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void EnsureNBits(int n, ref InputProcessor inputProcessor)
{
DecoderErrorCode errorCode = this.EnsureNBitsUnsafe(n, ref inputProcessor);
OldDecoderErrorCode errorCode = this.EnsureNBitsUnsafe(n, ref inputProcessor);
errorCode.EnsureNoError();
}

/// <summary>
/// Reads bytes from the byte buffer to ensure that bits.UnreadBits is at
/// least n. For best performance (avoiding function calls inside hot loops),
/// the caller is the one responsible for first checking that bits.UnreadBits &lt; n.
/// This method does not throw. Returns <see cref="DecoderErrorCode"/> instead.
/// This method does not throw. Returns <see cref="OldDecoderErrorCode"/> instead.
/// </summary>
/// <param name="n">The number of bits to ensure.</param>
/// <param name="inputProcessor">The <see cref="InputProcessor"/></param>
/// <returns>Error code</returns>
public DecoderErrorCode EnsureNBitsUnsafe(int n, ref InputProcessor inputProcessor)
public OldDecoderErrorCode EnsureNBitsUnsafe(int n, ref InputProcessor inputProcessor)
{
while (true)
{
DecoderErrorCode errorCode = this.EnsureBitsStepImpl(ref inputProcessor);
if (errorCode != DecoderErrorCode.NoError || this.UnreadBits >= n)
OldDecoderErrorCode errorCode = this.EnsureBitsStepImpl(ref inputProcessor);
if (errorCode != OldDecoderErrorCode.NoError || this.UnreadBits >= n)
{
return errorCode;
}
Expand All @@ -69,8 +69,8 @@ public DecoderErrorCode EnsureNBitsUnsafe(int n, ref InputProcessor inputProcess
/// Unrolled version of <see cref="EnsureNBitsUnsafe"/> for n==8
/// </summary>
/// <param name="inputProcessor">The <see cref="InputProcessor"/></param>
/// <returns>A <see cref="DecoderErrorCode"/></returns>
public DecoderErrorCode Ensure8BitsUnsafe(ref InputProcessor inputProcessor)
/// <returns>A <see cref="OldDecoderErrorCode"/></returns>
public OldDecoderErrorCode Ensure8BitsUnsafe(ref InputProcessor inputProcessor)
{
return this.EnsureBitsStepImpl(ref inputProcessor);
}
Expand All @@ -79,8 +79,8 @@ public DecoderErrorCode Ensure8BitsUnsafe(ref InputProcessor inputProcessor)
/// Unrolled version of <see cref="EnsureNBitsUnsafe"/> for n==1
/// </summary>
/// <param name="inputProcessor">The <see cref="InputProcessor"/></param>
/// <returns>A <see cref="DecoderErrorCode"/></returns>
public DecoderErrorCode Ensure1BitUnsafe(ref InputProcessor inputProcessor)
/// <returns>A <see cref="OldDecoderErrorCode"/></returns>
public OldDecoderErrorCode Ensure1BitUnsafe(ref InputProcessor inputProcessor)
{
return this.EnsureBitsStepImpl(ref inputProcessor);
}
Expand All @@ -95,7 +95,7 @@ public DecoderErrorCode Ensure1BitUnsafe(ref InputProcessor inputProcessor)
public int ReceiveExtend(int t, ref InputProcessor inputProcessor)
{
int x;
DecoderErrorCode errorCode = this.ReceiveExtendUnsafe(t, ref inputProcessor, out x);
OldDecoderErrorCode errorCode = this.ReceiveExtendUnsafe(t, ref inputProcessor, out x);
errorCode.EnsureNoError();
return x;
}
Expand All @@ -106,13 +106,13 @@ public int ReceiveExtend(int t, ref InputProcessor inputProcessor)
/// <param name="t">Byte</param>
/// <param name="inputProcessor">The <see cref="InputProcessor"/></param>
/// <param name="x">Read bits value</param>
/// <returns>The <see cref="DecoderErrorCode"/></returns>
public DecoderErrorCode ReceiveExtendUnsafe(int t, ref InputProcessor inputProcessor, out int x)
/// <returns>The <see cref="OldDecoderErrorCode"/></returns>
public OldDecoderErrorCode ReceiveExtendUnsafe(int t, ref InputProcessor inputProcessor, out int x)
{
if (this.UnreadBits < t)
{
DecoderErrorCode errorCode = this.EnsureNBitsUnsafe(t, ref inputProcessor);
if (errorCode != DecoderErrorCode.NoError)
OldDecoderErrorCode errorCode = this.EnsureNBitsUnsafe(t, ref inputProcessor);
if (errorCode != OldDecoderErrorCode.NoError)
{
x = int.MaxValue;
return errorCode;
Expand All @@ -129,15 +129,15 @@ public DecoderErrorCode ReceiveExtendUnsafe(int t, ref InputProcessor inputProce
x += ((-1) << t) + 1;
}

return DecoderErrorCode.NoError;
return OldDecoderErrorCode.NoError;
}

private DecoderErrorCode EnsureBitsStepImpl(ref InputProcessor inputProcessor)
private OldDecoderErrorCode EnsureBitsStepImpl(ref InputProcessor inputProcessor)
{
int c;
DecoderErrorCode errorCode = inputProcessor.Bytes.ReadByteStuffedByteUnsafe(inputProcessor.InputStream, out c);
OldDecoderErrorCode errorCode = inputProcessor.Bytes.ReadByteStuffedByteUnsafe(inputProcessor.InputStream, out c);

if (errorCode != DecoderErrorCode.NoError)
if (errorCode != OldDecoderErrorCode.NoError)
{
return errorCode;
}
Expand Down
54 changes: 27 additions & 27 deletions src/ImageSharp/Formats/Jpeg/GolangPort/Components/Decoder/Bytes.cs
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,8 @@ public void Dispose()
/// </summary>
/// <param name="inputStream">Input stream</param>
/// <param name="x">The result byte as <see cref="int"/></param>
/// <returns>The <see cref="DecoderErrorCode"/></returns>
public DecoderErrorCode ReadByteStuffedByteUnsafe(Stream inputStream, out int x)
/// <returns>The <see cref="OldDecoderErrorCode"/></returns>
public OldDecoderErrorCode ReadByteStuffedByteUnsafe(Stream inputStream, out int x)
{
// Take the fast path if bytes.buf contains at least two bytes.
if (this.I + 2 <= this.J)
Expand All @@ -97,48 +97,48 @@ public DecoderErrorCode ReadByteStuffedByteUnsafe(Stream inputStream, out int x)
this.UnreadableBytes = 1;
if (x != OldJpegConstants.Markers.XFFInt)
{
return DecoderErrorCode.NoError;
return OldDecoderErrorCode.NoError;
}

if (this.BufferAsInt[this.I] != 0x00)
{
return DecoderErrorCode.MissingFF00;
return OldDecoderErrorCode.MissingFF00;
}

this.I++;
this.UnreadableBytes = 2;
x = OldJpegConstants.Markers.XFF;
return DecoderErrorCode.NoError;
return OldDecoderErrorCode.NoError;
}

this.UnreadableBytes = 0;

DecoderErrorCode errorCode = this.ReadByteAsIntUnsafe(inputStream, out x);
OldDecoderErrorCode errorCode = this.ReadByteAsIntUnsafe(inputStream, out x);
this.UnreadableBytes = 1;
if (errorCode != DecoderErrorCode.NoError)
if (errorCode != OldDecoderErrorCode.NoError)
{
return errorCode;
}

if (x != OldJpegConstants.Markers.XFF)
{
return DecoderErrorCode.NoError;
return OldDecoderErrorCode.NoError;
}

errorCode = this.ReadByteAsIntUnsafe(inputStream, out x);
this.UnreadableBytes = 2;
if (errorCode != DecoderErrorCode.NoError)
if (errorCode != OldDecoderErrorCode.NoError)
{
return errorCode;
}

if (x != 0x00)
{
return DecoderErrorCode.MissingFF00;
return OldDecoderErrorCode.MissingFF00;
}

x = OldJpegConstants.Markers.XFF;
return DecoderErrorCode.NoError;
return OldDecoderErrorCode.NoError;
}

/// <summary>
Expand All @@ -150,25 +150,25 @@ public DecoderErrorCode ReadByteStuffedByteUnsafe(Stream inputStream, out int x)
public byte ReadByte(Stream inputStream)
{
byte result;
DecoderErrorCode errorCode = this.ReadByteUnsafe(inputStream, out result);
OldDecoderErrorCode errorCode = this.ReadByteUnsafe(inputStream, out result);
errorCode.EnsureNoError();
return result;
}

/// <summary>
/// Extracts the next byte, whether buffered or not buffered into the result out parameter. It does not care about byte stuffing.
/// This method does not throw on format error, it returns a <see cref="DecoderErrorCode"/> instead.
/// This method does not throw on format error, it returns a <see cref="OldDecoderErrorCode"/> instead.
/// </summary>
/// <param name="inputStream">Input stream</param>
/// <param name="result">The result <see cref="byte"/> as out parameter</param>
/// <returns>The <see cref="DecoderErrorCode"/></returns>
public DecoderErrorCode ReadByteUnsafe(Stream inputStream, out byte result)
/// <returns>The <see cref="OldDecoderErrorCode"/></returns>
public OldDecoderErrorCode ReadByteUnsafe(Stream inputStream, out byte result)
{
DecoderErrorCode errorCode = DecoderErrorCode.NoError;
OldDecoderErrorCode errorCode = OldDecoderErrorCode.NoError;
while (this.I == this.J)
{
errorCode = this.FillUnsafe(inputStream);
if (errorCode != DecoderErrorCode.NoError)
if (errorCode != OldDecoderErrorCode.NoError)
{
result = 0;
return errorCode;
Expand All @@ -186,15 +186,15 @@ public DecoderErrorCode ReadByteUnsafe(Stream inputStream, out byte result)
/// </summary>
/// <param name="inputStream">The input stream</param>
/// <param name="result">The result <see cref="int"/></param>
/// <returns>A <see cref="DecoderErrorCode"/></returns>
/// <returns>A <see cref="OldDecoderErrorCode"/></returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public DecoderErrorCode ReadByteAsIntUnsafe(Stream inputStream, out int result)
public OldDecoderErrorCode ReadByteAsIntUnsafe(Stream inputStream, out int result)
{
DecoderErrorCode errorCode = DecoderErrorCode.NoError;
OldDecoderErrorCode errorCode = OldDecoderErrorCode.NoError;
while (this.I == this.J)
{
errorCode = this.FillUnsafe(inputStream);
if (errorCode != DecoderErrorCode.NoError)
if (errorCode != OldDecoderErrorCode.NoError)
{
result = 0;
return errorCode;
Expand All @@ -216,18 +216,18 @@ public DecoderErrorCode ReadByteAsIntUnsafe(Stream inputStream, out int result)
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void Fill(Stream inputStream)
{
DecoderErrorCode errorCode = this.FillUnsafe(inputStream);
OldDecoderErrorCode errorCode = this.FillUnsafe(inputStream);
errorCode.EnsureNoError();
}

/// <summary>
/// Fills up the bytes buffer from the underlying stream.
/// It should only be called when there are no unread bytes in bytes.
/// This method does not throw <see cref="EOFException"/>, returns a <see cref="DecoderErrorCode"/> instead!
/// This method does not throw <see cref="EOFException"/>, returns a <see cref="OldDecoderErrorCode"/> instead!
/// </summary>
/// <param name="inputStream">Input stream</param>
/// <returns>The <see cref="DecoderErrorCode"/></returns>
public DecoderErrorCode FillUnsafe(Stream inputStream)
/// <returns>The <see cref="OldDecoderErrorCode"/></returns>
public OldDecoderErrorCode FillUnsafe(Stream inputStream)
{
if (this.I != this.J)
{
Expand All @@ -249,7 +249,7 @@ public DecoderErrorCode FillUnsafe(Stream inputStream)
int n = inputStream.Read(this.Buffer, this.J, this.Buffer.Length - this.J);
if (n == 0)
{
return DecoderErrorCode.UnexpectedEndOfStream;
return OldDecoderErrorCode.UnexpectedEndOfStream;
}

this.J += n;
Expand All @@ -259,7 +259,7 @@ public DecoderErrorCode FillUnsafe(Stream inputStream)
this.BufferAsInt[i] = this.Buffer[i];
}

return DecoderErrorCode.NoError;
return OldDecoderErrorCode.NoError;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,46 +14,46 @@ namespace ImageSharp.Formats.Jpeg.GolangPort.Components.Decoder
internal static class DecoderThrowHelper
{
/// <summary>
/// Throws an exception that belongs to the given <see cref="DecoderErrorCode"/>
/// Throws an exception that belongs to the given <see cref="OldDecoderErrorCode"/>
/// </summary>
/// <param name="errorCode">The <see cref="DecoderErrorCode"/></param>
/// <param name="errorCode">The <see cref="OldDecoderErrorCode"/></param>
[MethodImpl(MethodImplOptions.NoInlining)]
public static void ThrowExceptionForErrorCode(this DecoderErrorCode errorCode)
public static void ThrowExceptionForErrorCode(this OldDecoderErrorCode errorCode)
{
switch (errorCode)
{
case DecoderErrorCode.NoError:
case OldDecoderErrorCode.NoError:
throw new ArgumentException("ThrowExceptionForErrorCode() called with NoError!", nameof(errorCode));
case DecoderErrorCode.MissingFF00:
case OldDecoderErrorCode.MissingFF00:
throw new MissingFF00Exception();
case DecoderErrorCode.UnexpectedEndOfStream:
case OldDecoderErrorCode.UnexpectedEndOfStream:
throw new EOFException();
default:
throw new ArgumentOutOfRangeException(nameof(errorCode), errorCode, null);
}
}

/// <summary>
/// Throws an exception if the given <see cref="DecoderErrorCode"/> defines an error.
/// Throws an exception if the given <see cref="OldDecoderErrorCode"/> defines an error.
/// </summary>
/// <param name="errorCode">The <see cref="DecoderErrorCode"/></param>
/// <param name="errorCode">The <see cref="OldDecoderErrorCode"/></param>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static void EnsureNoError(this DecoderErrorCode errorCode)
public static void EnsureNoError(this OldDecoderErrorCode errorCode)
{
if (errorCode != DecoderErrorCode.NoError)
if (errorCode != OldDecoderErrorCode.NoError)
{
ThrowExceptionForErrorCode(errorCode);
}
}

/// <summary>
/// Throws an exception if the given <see cref="DecoderErrorCode"/> is <see cref="DecoderErrorCode.UnexpectedEndOfStream"/>.
/// Throws an exception if the given <see cref="OldDecoderErrorCode"/> is <see cref="OldDecoderErrorCode.UnexpectedEndOfStream"/>.
/// </summary>
/// <param name="errorCode">The <see cref="DecoderErrorCode"/></param>
/// <param name="errorCode">The <see cref="OldDecoderErrorCode"/></param>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static void EnsureNoEOF(this DecoderErrorCode errorCode)
public static void EnsureNoEOF(this OldDecoderErrorCode errorCode)
{
if (errorCode == DecoderErrorCode.UnexpectedEndOfStream)
if (errorCode == OldDecoderErrorCode.UnexpectedEndOfStream)
{
errorCode.ThrowExceptionForErrorCode();
}
Expand Down
Loading

0 comments on commit 493deda

Please sign in to comment.