Skip to content

Commit

Permalink
Remove space in cast formatting for Direct and PackedThreeBlocks, #1008
Browse files Browse the repository at this point in the history
  • Loading branch information
paulirwin committed Dec 17, 2024
1 parent 56c14ed commit aca5fb5
Show file tree
Hide file tree
Showing 7 changed files with 41 additions and 41 deletions.
10 changes: 5 additions & 5 deletions src/Lucene.Net/Util/Packed/Direct16.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ internal Direct16(int packedIntsVersion, DataInput @in, int valueCount)
values[i] = @in.ReadInt16();
}
// because packed ints have not always been byte-aligned
int remaining = (int) (PackedInt32s.Format.PACKED.ByteCount(packedIntsVersion, valueCount, 16) - 2L * valueCount);
int remaining = (int)(PackedInt32s.Format.PACKED.ByteCount(packedIntsVersion, valueCount, 16) - 2L * valueCount);
for (int i = 0; i < remaining; ++i)
{
@in.ReadByte();
Expand All @@ -65,7 +65,7 @@ public override long Get(int index)
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public override void Set(int index, long value)
{
values[index] = (short) (value);
values[index] = (short)(value);
}

public override long RamBytesUsed()
Expand All @@ -80,7 +80,7 @@ public override long RamBytesUsed()
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public override void Clear()
{
Arrays.Fill(values, (short) 0L);
Arrays.Fill(values, (short)0L);
}

[MethodImpl(MethodImplOptions.AggressiveInlining)]
Expand Down Expand Up @@ -120,7 +120,7 @@ public override int Set(int index, long[] arr, int off, int len)
int sets = Math.Min(m_valueCount - index, len);
for (int i = index, o = off, end = index + sets; i < end; ++i, ++o)
{
values[i] = (short) arr[o];
values[i] = (short)arr[o];
}
return sets;
}
Expand All @@ -129,7 +129,7 @@ public override int Set(int index, long[] arr, int off, int len)
public override void Fill(int fromIndex, int toIndex, long val)
{
if (Debugging.AssertsEnabled) Debugging.Assert(val == (val & 0xFFFFL));
Arrays.Fill(values, fromIndex, toIndex, (short) val);
Arrays.Fill(values, fromIndex, toIndex, (short)val);
}
}
}
10 changes: 5 additions & 5 deletions src/Lucene.Net/Util/Packed/Direct32.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ internal Direct32(int packedIntsVersion, DataInput @in, int valueCount)
values[i] = @in.ReadInt32();
}
// because packed ints have not always been byte-aligned
int remaining = (int) (PackedInt32s.Format.PACKED.ByteCount(packedIntsVersion, valueCount, 32) - 4L * valueCount);
int remaining = (int)(PackedInt32s.Format.PACKED.ByteCount(packedIntsVersion, valueCount, 32) - 4L * valueCount);
for (int i = 0; i < remaining; ++i)
{
@in.ReadByte();
Expand All @@ -65,7 +65,7 @@ public override long Get(int index)
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public override void Set(int index, long value)
{
values[index] = (int) (value);
values[index] = (int)(value);
}

public override long RamBytesUsed()
Expand All @@ -80,7 +80,7 @@ public override long RamBytesUsed()
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public override void Clear()
{
Arrays.Fill(values, (int) 0L);
Arrays.Fill(values, (int)0L);
}

[MethodImpl(MethodImplOptions.AggressiveInlining)]
Expand Down Expand Up @@ -120,7 +120,7 @@ public override int Set(int index, long[] arr, int off, int len)
int sets = Math.Min(m_valueCount - index, len);
for (int i = index, o = off, end = index + sets; i < end; ++i, ++o)
{
values[i] = (int) arr[o];
values[i] = (int)arr[o];
}
return sets;
}
Expand All @@ -129,7 +129,7 @@ public override int Set(int index, long[] arr, int off, int len)
public override void Fill(int fromIndex, int toIndex, long val)
{
if (Debugging.AssertsEnabled) Debugging.Assert(val == (val & 0xFFFFFFFFL));
Arrays.Fill(values, fromIndex, toIndex, (int) val);
Arrays.Fill(values, fromIndex, toIndex, (int)val);
}
}
}
10 changes: 5 additions & 5 deletions src/Lucene.Net/Util/Packed/Direct8.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ internal Direct8(int packedIntsVersion, DataInput @in, int valueCount)
{
@in.ReadBytes(values, 0, valueCount);
// because packed ints have not always been byte-aligned
int remaining = (int) (PackedInt32s.Format.PACKED.ByteCount(packedIntsVersion, valueCount, 8) - 1L * valueCount);
int remaining = (int)(PackedInt32s.Format.PACKED.ByteCount(packedIntsVersion, valueCount, 8) - 1L * valueCount);
for (int i = 0; i < remaining; ++i)
{
@in.ReadByte();
Expand All @@ -62,7 +62,7 @@ public override long Get(int index)
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public override void Set(int index, long value)
{
values[index] = (byte) (value);
values[index] = (byte)(value);
}

public override long RamBytesUsed()
Expand All @@ -77,7 +77,7 @@ public override long RamBytesUsed()
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public override void Clear()
{
Arrays.Fill(values, (byte) 0L);
Arrays.Fill(values, (byte)0L);
}

[MethodImpl(MethodImplOptions.AggressiveInlining)]
Expand Down Expand Up @@ -117,7 +117,7 @@ public override int Set(int index, long[] arr, int off, int len)
int sets = Math.Min(m_valueCount - index, len);
for (int i = index, o = off, end = index + sets; i < end; ++i, ++o)
{
values[i] = (byte) arr[o];
values[i] = (byte)arr[o];
}
return sets;
}
Expand All @@ -126,7 +126,7 @@ public override int Set(int index, long[] arr, int off, int len)
public override void Fill(int fromIndex, int toIndex, long val)
{
if (Debugging.AssertsEnabled) Debugging.Assert(val == (val & 0xFFL));
Arrays.Fill(values, fromIndex, toIndex, (byte) val);
Arrays.Fill(values, fromIndex, toIndex, (byte)val);
}
}
}
22 changes: 11 additions & 11 deletions src/Lucene.Net/Util/Packed/Packed16ThreeBlocks.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ internal Packed16ThreeBlocks(int packedIntsVersion, DataInput @in, int valueCoun
blocks[i] = @in.ReadInt16();
}
// because packed ints have not always been byte-aligned
int remaining = (int) (PackedInt32s.Format.PACKED.ByteCount(packedIntsVersion, valueCount, 48) - 3L * valueCount * 2);
int remaining = (int)(PackedInt32s.Format.PACKED.ByteCount(packedIntsVersion, valueCount, 48) - 3L * valueCount * 2);
for (int i = 0; i < remaining; ++i)
{
@in.ReadByte();
Expand Down Expand Up @@ -89,9 +89,9 @@ public override int Get(int index, long[] arr, int off, int len)
public override void Set(int index, long value)
{
int o = index * 3;
blocks[o] = (short) (value >>> 32);
blocks[o + 1] = (short) (value >>> 16);
blocks[o + 2] = (short) value;
blocks[o] = (short)(value >>> 32);
blocks[o + 1] = (short)(value >>> 16);
blocks[o + 2] = (short)value;
}

public override int Set(int index, long[] arr, int off, int len)
Expand All @@ -107,18 +107,18 @@ public override int Set(int index, long[] arr, int off, int len)
for (int i = off, o = index * 3, end = off + sets; i < end; ++i)
{
long value = arr[i];
blocks[o++] = (short) (value >>> 32);
blocks[o++] = (short) (value >>> 16);
blocks[o++] = (short) value;
blocks[o++] = (short)(value >>> 32);
blocks[o++] = (short)(value >>> 16);
blocks[o++] = (short)value;
}
return sets;
}

public override void Fill(int fromIndex, int toIndex, long val)
{
short block1 = (short) (val >>> 32);
short block2 = (short) (val >>> 16);
short block3 = (short) val;
short block1 = (short)(val >>> 32);
short block2 = (short)(val >>> 16);
short block3 = (short)val;
for (int i = fromIndex * 3, end = toIndex * 3; i < end; i += 3)
{
blocks[i] = block1;
Expand All @@ -130,7 +130,7 @@ public override void Fill(int fromIndex, int toIndex, long val)
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public override void Clear()
{
Arrays.Fill(blocks, (short) 0);
Arrays.Fill(blocks, (short)0);
}

public override long RamBytesUsed()
Expand Down
22 changes: 11 additions & 11 deletions src/Lucene.Net/Util/Packed/Packed8ThreeBlocks.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ internal Packed8ThreeBlocks(int packedIntsVersion, DataInput @in, int valueCount
{
@in.ReadBytes(blocks, 0, 3 * valueCount);
// because packed ints have not always been byte-aligned
int remaining = (int) (PackedInt32s.Format.PACKED.ByteCount(packedIntsVersion, valueCount, 24) - 3L * valueCount * 1);
int remaining = (int)(PackedInt32s.Format.PACKED.ByteCount(packedIntsVersion, valueCount, 24) - 3L * valueCount * 1);
for (int i = 0; i < remaining; ++i)
{
@in.ReadByte();
Expand Down Expand Up @@ -86,9 +86,9 @@ public override int Get(int index, long[] arr, int off, int len)
public override void Set(int index, long value)
{
int o = index * 3;
blocks[o] = (byte) (value >>> 16);
blocks[o + 1] = (byte) (value >>> 8);
blocks[o + 2] = (byte) value;
blocks[o] = (byte)(value >>> 16);
blocks[o + 1] = (byte)(value >>> 8);
blocks[o + 2] = (byte)value;
}

public override int Set(int index, long[] arr, int off, int len)
Expand All @@ -104,18 +104,18 @@ public override int Set(int index, long[] arr, int off, int len)
for (int i = off, o = index * 3, end = off + sets; i < end; ++i)
{
long value = arr[i];
blocks[o++] = (byte) (value >>> 16);
blocks[o++] = (byte) (value >>> 8);
blocks[o++] = (byte) value;
blocks[o++] = (byte)(value >>> 16);
blocks[o++] = (byte)(value >>> 8);
blocks[o++] = (byte)value;
}
return sets;
}

public override void Fill(int fromIndex, int toIndex, long val)
{
byte block1 = (byte) (val >>> 16);
byte block2 = (byte) (val >>> 8);
byte block3 = (byte) val;
byte block1 = (byte)(val >>> 16);
byte block2 = (byte)(val >>> 8);
byte block3 = (byte)val;
for (int i = fromIndex * 3, end = toIndex * 3; i < end; i += 3)
{
blocks[i] = block1;
Expand All @@ -127,7 +127,7 @@ public override void Fill(int fromIndex, int toIndex, long val)
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public override void Clear()
{
Arrays.Fill(blocks, (byte) 0);
Arrays.Fill(blocks, (byte)0);
}

public override long RamBytesUsed()
Expand Down
4 changes: 2 additions & 2 deletions src/Lucene.Net/Util/Packed/gen_Direct.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
TYPES = {8: "byte", 16: "short", 32: "int", 64: "long"}
DOTNET_READ_TYPES = {8: "Byte", 16: "Int16", 32: "Int32", 64: "Int64"} # LUCENENET specific
MASKS = {8: " & 0xFFL", 16: " & 0xFFFFL", 32: " & 0xFFFFFFFFL", 64: ""}
CASTS = {8: "(byte) ", 16: "(short) ", 32: "(int) ", 64: ""}
CASTS = {8: "(byte)", 16: "(short)", 32: "(int)", 64: ""} # LUCENENET specific - removed space from casts to match existing C# port style

if __name__ == '__main__':
for bpv in TYPES.keys():
Expand Down Expand Up @@ -94,7 +94,7 @@
f.write(" }\n")
if bpv != 64:
f.write(" // because packed ints have not always been byte-aligned\n")
f.write(" int remaining = (int) (PackedInt32s.Format.PACKED.ByteCount(packedIntsVersion, valueCount, %d) - %dL * valueCount);\n" %(bpv, bpv / 8))
f.write(" int remaining = (int)(PackedInt32s.Format.PACKED.ByteCount(packedIntsVersion, valueCount, %d) - %dL * valueCount);\n" %(bpv, bpv / 8))
f.write(" for (int i = 0; i < remaining; ++i)\n")
f.write(" {\n")
f.write(" @in.ReadByte();\n")
Expand Down
4 changes: 2 additions & 2 deletions src/Lucene.Net/Util/Packed/gen_PackedThreeBlocks.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
TYPES = {8: "byte", 16: "short"}
DOTNET_READ_TYPES = {8: "Byte", 16: "Int16"} # LUCENENET specific
MASKS = {8: " & 0xFFL", 16: " & 0xFFFFL", 32: " & 0xFFFFFFFFL", 64: ""}
CASTS = {8: "(byte) ", 16: "(short) ", 32: "(int) ", 64: ""}
CASTS = {8: "(byte)", 16: "(short)", 32: "(int)", 64: ""} # LUCENENET specific - removed space from casts to match existing C# port style

if __name__ == '__main__':
for bpv in TYPES.keys():
Expand Down Expand Up @@ -91,7 +91,7 @@
f.write(" blocks[i] = @in.Read%s();\n" %DOTNET_READ_TYPES[bpv].title()) # LUCENENET specific
f.write(" }\n")
f.write(" // because packed ints have not always been byte-aligned\n")
f.write(" int remaining = (int) (PackedInt32s.Format.PACKED.ByteCount(packedIntsVersion, valueCount, %d) - 3L * valueCount * %d);\n" %(3 * bpv, bpv / 8))
f.write(" int remaining = (int)(PackedInt32s.Format.PACKED.ByteCount(packedIntsVersion, valueCount, %d) - 3L * valueCount * %d);\n" %(3 * bpv, bpv / 8))
f.write(" for (int i = 0; i < remaining; ++i)\n")
f.write(" {\n")
f.write(" @in.ReadByte();\n")
Expand Down

0 comments on commit aca5fb5

Please sign in to comment.