Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -226,73 +226,89 @@ public override bool IsNull(int record)
public override void Set(int recordNo, object value)
{
Debug.Assert(null != value, "null value");

if (_nullValue == value)
{
_values[recordNo] = null;
return;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the aim behind replacing else blocks with many duplicated returns?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To use a single throw at the end of the method whilst keeping the control flow simple. The JIT will create a single exit.

If this is less readable I can revert to else blocks.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@MihaZupan What is your view on this?

}
else if (_dataType == typeof(object) || _dataType.IsInstanceOfType(value))

if (_dataType == typeof(object) || _dataType.IsInstanceOfType(value))
{
_values[recordNo] = value;
return;
}
else

if (_dataType == typeof(Guid) && value.GetType() == typeof(string))
{
_values[recordNo] = new Guid((string)value);
return;
}

if (_dataType == typeof(byte[]))
{
Type valType = value.GetType();
if (_dataType == typeof(Guid) && valType == typeof(string))
if (value.GetType() == typeof(bool))
{
_values[recordNo] = new Guid((string)value);
_values[recordNo] = BitConverter.GetBytes((bool)value);
return;
}
else if (_dataType == typeof(byte[]))

if (value.GetType() == typeof(char))
{
if (valType == typeof(bool))
{
_values[recordNo] = BitConverter.GetBytes((bool)value);
}
else if (valType == typeof(char))
{
_values[recordNo] = BitConverter.GetBytes((char)value);
}
else if (valType == typeof(short))
{
_values[recordNo] = BitConverter.GetBytes((short)value);
}
else if (valType == typeof(int))
{
_values[recordNo] = BitConverter.GetBytes((int)value);
}
else if (valType == typeof(long))
{
_values[recordNo] = BitConverter.GetBytes((long)value);
}
else if (valType == typeof(ushort))
{
_values[recordNo] = BitConverter.GetBytes((ushort)value);
}
else if (valType == typeof(uint))
{
_values[recordNo] = BitConverter.GetBytes((uint)value);
}
else if (valType == typeof(ulong))
{
_values[recordNo] = BitConverter.GetBytes((ulong)value);
}
else if (valType == typeof(float))
{
_values[recordNo] = BitConverter.GetBytes((float)value);
}
else if (valType == typeof(double))
{
_values[recordNo] = BitConverter.GetBytes((double)value);
}
else
{
throw ExceptionBuilder.StorageSetFailed();
}
_values[recordNo] = BitConverter.GetBytes((char)value);
return;
}
else

if (value.GetType() == typeof(short))
{
_values[recordNo] = BitConverter.GetBytes((short)value);
return;
}

if (value.GetType() == typeof(int))
{
_values[recordNo] = BitConverter.GetBytes((int)value);
return;
}

if (value.GetType() == typeof(long))
{
_values[recordNo] = BitConverter.GetBytes((long)value);
return;
}

if (value.GetType() == typeof(ushort))
{
throw ExceptionBuilder.StorageSetFailed();
_values[recordNo] = BitConverter.GetBytes((ushort)value);
return;
}

if (value.GetType() == typeof(uint))
{
_values[recordNo] = BitConverter.GetBytes((uint)value);
return;
}

if (value.GetType() == typeof(ulong))
{
_values[recordNo] = BitConverter.GetBytes((ulong)value);
return;
}

if (value.GetType() == typeof(float))
{
_values[recordNo] = BitConverter.GetBytes((float)value);
return;
}

if (value.GetType() == typeof(double))
{
_values[recordNo] = BitConverter.GetBytes((double)value);
return;
}
}

throw ExceptionBuilder.StorageSetFailed();
}

public override void SetCapacity(int capacity)
Expand Down