Skip to content

Commit

Permalink
[Java] Remove more redundant casts. Issue #766.
Browse files Browse the repository at this point in the history
  • Loading branch information
mjpt777 committed Mar 25, 2020
1 parent f491d59 commit a2ebaf9
Showing 1 changed file with 6 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -459,15 +459,17 @@ private void generateGroupEncoderClassHeader(

final PrimitiveType blockLengthType = blockLengthToken.encoding().primitiveType();
final String blockLengthOffset = "limit + " + blockLengthToken.offset();
final String blockLengthValue = "(" + primitiveTypeName(blockLengthToken) + ")" + blockLength;
final String blockLengthValue = Integer.toString(blockLength);
final String blockLengthPut = generatePut(
blockLengthType, blockLengthOffset, blockLengthValue, byteOrderString(blockLengthToken.encoding()));

final PrimitiveType numInGroupType = numInGroupToken.encoding().primitiveType();
final PrimitiveType newInGroupTypeCast = PrimitiveType.UINT32 == numInGroupType ?
PrimitiveType.INT32 : numInGroupType;
final String numInGroupOffset = "limit + " + numInGroupToken.offset();
final String numInGroupValue = "(" + primitiveTypeName(numInGroupToken) + ")count";
final String numInGroupValue = "count";
final String numInGroupPut = generatePut(
numInGroupType, numInGroupOffset, numInGroupValue, byteOrderString(numInGroupToken.encoding()));
newInGroupTypeCast, numInGroupOffset, numInGroupValue, byteOrderString(numInGroupToken.encoding()));

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

final String countOffset = "initialLimit + " + numInGroupToken.offset();
final String resetCountPut = generatePut(
numInGroupType, countOffset, numInGroupValue, byteOrderString(numInGroupToken.encoding()));
newInGroupTypeCast, countOffset, numInGroupValue, byteOrderString(numInGroupToken.encoding()));

sb.append("\n")
.append(ind).append(" public int resetCountToIndex()\n")
Expand Down

0 comments on commit a2ebaf9

Please sign in to comment.