Skip to content

Commit 43ee658

Browse files
committed
[C#] Tidy up after merge of PR #845.
1 parent 7690fae commit 43ee658

14 files changed

+203
-202
lines changed

csharp/sbe-benchmarks/Bench/SBE/CarBenchmark.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ public int Decode(Car car, DirectBuffer directBuffer, int bufferOffset)
184184
while (performanceFiguresGroup.HasNext)
185185
{
186186
performanceFiguresGroup.Next();
187-
var octanceRating = performanceFiguresGroup.OctaneRating;
187+
var octaneRating = performanceFiguresGroup.OctaneRating;
188188

189189
var accelerationGroup = performanceFiguresGroup.Acceleration;
190190
for (int i = 0; i < accelerationGroup.Count; i++)

csharp/sbe-benchmarks/Bench/SBE/CarBenchmark_with_strings_new.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ namespace Org.SbeTool.Sbe.Benchmarks.Bench.Benchmarks
99
[MemoryDiagnoser]
1010
public class CarBenchmark_with_strings_new
1111
{
12-
1312
private readonly byte[] _eBuffer = new byte[1024];
1413
private readonly byte[] _dBuffer = new byte[1024];
1514
private DirectBuffer _encodeBuffer;
@@ -173,7 +172,7 @@ public int Decode(Car car, DirectBuffer directBuffer, int bufferOffset)
173172
while (performanceFiguresGroup.HasNext)
174173
{
175174
performanceFiguresGroup.Next();
176-
var octanceRating = performanceFiguresGroup.OctaneRating;
175+
var octaneRating = performanceFiguresGroup.OctaneRating;
177176

178177
var accelerationGroup = performanceFiguresGroup.Acceleration;
179178
for (int i = 0; i < accelerationGroup.Count; i++)
@@ -187,6 +186,7 @@ public int Decode(Car car, DirectBuffer directBuffer, int bufferOffset)
187186
var man = car.GetManufacturer();
188187
var model = car.GetModel();
189188
var actCode = car.GetActivationCode();
189+
190190
return car.Size;
191191
}
192192
}

csharp/sbe-benchmarks/Bench/SBE/CarBenchmark_with_strings_original.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,13 @@ namespace Org.SbeTool.Sbe.Benchmarks.Bench.Benchmarks
99
[MemoryDiagnoser]
1010
public class CarBenchmark_with_strings_original
1111
{
12-
1312
private static readonly Encoding VehicleCodeEncoding = Encoding.GetEncoding(Car.VehicleCodeCharacterEncoding);
1413
private static readonly Encoding ManufacturerCodeEncoding = Encoding.GetEncoding(Engine.ManufacturerCodeCharacterEncoding);
1514
private static readonly Encoding ManufacturerEncoding = Encoding.GetEncoding(Car.ManufacturerCharacterEncoding);
1615
private static readonly Encoding ModelEncoding = Encoding.GetEncoding(Car.ModelCharacterEncoding);
1716
private static readonly Encoding ActivationCodeEncoding = Encoding.GetEncoding(Car.ActivationCodeCharacterEncoding);
1817
private static readonly Encoding UsageDescriptionEncoding = Encoding.GetEncoding(Car.FuelFiguresGroup.UsageDescriptionCharacterEncoding);
1918

20-
2119
private readonly byte[] _eBuffer = new byte[1024];
2220
private readonly byte[] _dBuffer = new byte[1024];
2321
private DirectBuffer _encodeBuffer;
@@ -187,7 +185,7 @@ public int Decode(Car car, DirectBuffer directBuffer, int bufferOffset)
187185
while (performanceFiguresGroup.HasNext)
188186
{
189187
performanceFiguresGroup.Next();
190-
var octanceRating = performanceFiguresGroup.OctaneRating;
188+
var octaneRating = performanceFiguresGroup.OctaneRating;
191189

192190
var accelerationGroup = performanceFiguresGroup.Acceleration;
193191
for (int i = 0; i < accelerationGroup.Count; i++)

csharp/sbe-benchmarks/Bench/SBE/MarketDataBenchmark.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,4 +103,4 @@ public int Decode(DirectBuffer buffer, int bufferOffset)
103103
return _marketData.Size;
104104
}
105105
}
106-
}
106+
}

csharp/sbe-dll/DirectBuffer.cs

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -657,23 +657,22 @@ public int SetBytes(int index, ReadOnlySpan<byte> src)
657657

658658
/// <summary>
659659
/// Writes a string into the underlying buffer, encoding using the provided <see cref="System.Text.Encoding"/>.
660-
/// If there is not enough room in the buffer for the bytes it will throw IndexOutOfRangeExcpetion.
660+
/// If there is not enough room in the buffer for the bytes it will throw IndexOutOfRangeException.
661661
/// </summary>
662662
/// <param name="encoding">encoding to use to write the bytes from the string</param>
663663
/// <param name="src">source string</param>
664664
/// <param name="index">index in the underlying buffer to start writing bytes</param>
665665
/// <returns>count of bytes written</returns>
666666
public unsafe int SetBytesFromString(Encoding encoding, string src, int index)
667667
{
668-
669668
int available = _capacity - index;
670-
671669
int byteCount = encoding.GetByteCount(src);
672670

673671
if (byteCount > available)
674672
{
675673
ThrowHelper.ThrowIndexOutOfRangeException(_capacity);
676674
}
675+
677676
fixed (char* ptr = src)
678677
{
679678
return encoding.GetBytes(ptr, src.Length, _pBuffer + index, byteCount);
@@ -686,7 +685,7 @@ public unsafe int SetBytesFromString(Encoding encoding, string src, int index)
686685
/// If there are not enough bytes in the buffer it will throw an IndexOutOfRangeException.
687686
/// </summary>
688687
/// <param name="encoding">encoding to use to convert the bytes into characters</param>
689-
/// <param name="index">index in theunderlying buffer to start writing bytes</param>
688+
/// <param name="index">index in the underlying buffer to start writing bytes</param>
690689
/// <param name="byteCount">the number of bytes to read into the string</param>
691690
/// <returns>the string representing the decoded bytes read from the buffer</returns>
692691
public string GetStringFromBytes(Encoding encoding, int index, int byteCount)
@@ -715,14 +714,17 @@ public unsafe string GetStringFromNullTerminatedBytes(Encoding encoding, int ind
715714
{
716715
ThrowHelper.ThrowIndexOutOfRangeException(index);
717716
}
717+
718718
if (_pBuffer[index] == nullByte)
719719
{
720720
return null;
721721
}
722+
722723
int byteCount2 = 0;
723724
for (byteCount2 = 0; byteCount2 < count && _pBuffer[byteCount2 + index] != nullByte; byteCount2++)
724725
{
725726
}
727+
726728
return new String((sbyte*) _pBuffer, index, byteCount2, encoding);
727729
}
728730

@@ -743,25 +745,30 @@ public unsafe int SetNullTerminatedBytesFromString(Encoding encoding, string src
743745
{
744746
ThrowHelper.ThrowIndexOutOfRangeException(index);
745747
}
748+
746749
if (src == null)
747750
{
748751
_pBuffer[index] = nullByte;
749752
return 1;
750753
}
754+
751755
int byteCount = encoding.GetByteCount(src);
752756
if (byteCount > available)
753757
{
754758
ThrowHelper.ThrowIndexOutOfRangeException(index + available);
755759
}
760+
756761
fixed (char* ptr = src)
757762
{
758763
encoding.GetBytes(ptr, src.Length, _pBuffer + index, byteCount);
759764
}
765+
760766
if (byteCount < available)
761767
{
762768
*(_pBuffer + index + byteCount) = nullByte;
763769
return byteCount + 1;
764770
}
771+
765772
return byteCount;
766773
}
767774

csharp/sbe-dll/EndianessConverter.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ namespace Org.SbeTool.Sbe.Dll
88
/// </summary>
99
public static class EndianessConverter
1010
{
11-
// TODO: we could assume the system is always little endian and have two methods for each (one no-op and another one which reverse, so we do not have branching)
11+
// TODO: we could assume the system is always little endian and have two methods for each
12+
// TODO: (one no-op and another one which reverse, so we do not have branching)
1213

1314
private static readonly ByteOrder NativeByteOrder = BitConverter.IsLittleEndian
1415
? ByteOrder.LittleEndian

csharp/sbe-dll/PrimitiveType.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,4 +208,4 @@ public SbePrimitiveType Type
208208
get { return _sbePrimitiveType; }
209209
}
210210
}
211-
}
211+
}

csharp/sbe-dll/PrimitiveValue.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,6 @@ private enum Representation
104104
#endregion
105105

106106

107-
108107
/// <summary>
109108
/// Minimum value for INT8 SBE type
110109
/// </summary>
@@ -537,4 +536,4 @@ public override int GetHashCode()
537536
}
538537
}
539538
}
540-
}
539+
}

csharp/sbe-dll/SbePrimitiveType.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,4 +60,4 @@ public enum SbePrimitiveType
6060
/// </summary>
6161
Double
6262
}
63-
}
63+
}

csharp/sbe-dll/sbe-tool.sh

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
ROOTDIR=$(dirname ${0})
44
SBE_JAR=${ROOTDIR}/sbe-tool-all.jar
55

6-
76
[ -f "${SBE_JAR}" ] || (echo "Missing ${SBE_JAR}"; exit 1)
87

98
function usage {

0 commit comments

Comments
 (0)