Skip to content

Commit a2ebaf9

Browse files
committed
[Java] Remove more redundant casts. Issue #766.
1 parent f491d59 commit a2ebaf9

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

sbe-tool/src/main/java/uk/co/real_logic/sbe/generation/java/JavaGenerator.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -459,15 +459,17 @@ private void generateGroupEncoderClassHeader(
459459

460460
final PrimitiveType blockLengthType = blockLengthToken.encoding().primitiveType();
461461
final String blockLengthOffset = "limit + " + blockLengthToken.offset();
462-
final String blockLengthValue = "(" + primitiveTypeName(blockLengthToken) + ")" + blockLength;
462+
final String blockLengthValue = Integer.toString(blockLength);
463463
final String blockLengthPut = generatePut(
464464
blockLengthType, blockLengthOffset, blockLengthValue, byteOrderString(blockLengthToken.encoding()));
465465

466466
final PrimitiveType numInGroupType = numInGroupToken.encoding().primitiveType();
467+
final PrimitiveType newInGroupTypeCast = PrimitiveType.UINT32 == numInGroupType ?
468+
PrimitiveType.INT32 : numInGroupType;
467469
final String numInGroupOffset = "limit + " + numInGroupToken.offset();
468-
final String numInGroupValue = "(" + primitiveTypeName(numInGroupToken) + ")count";
470+
final String numInGroupValue = "count";
469471
final String numInGroupPut = generatePut(
470-
numInGroupType, numInGroupOffset, numInGroupValue, byteOrderString(numInGroupToken.encoding()));
472+
newInGroupTypeCast, numInGroupOffset, numInGroupValue, byteOrderString(numInGroupToken.encoding()));
471473

472474
new Formatter(sb).format("\n" +
473475
ind + " public void wrap(final %2$s buffer, final int count)\n" +
@@ -510,7 +512,7 @@ private void generateGroupEncoderClassHeader(
510512

511513
final String countOffset = "initialLimit + " + numInGroupToken.offset();
512514
final String resetCountPut = generatePut(
513-
numInGroupType, countOffset, numInGroupValue, byteOrderString(numInGroupToken.encoding()));
515+
newInGroupTypeCast, countOffset, numInGroupValue, byteOrderString(numInGroupToken.encoding()));
514516

515517
sb.append("\n")
516518
.append(ind).append(" public int resetCountToIndex()\n")

0 commit comments

Comments
 (0)