Skip to content

Commit

Permalink
perf[golang]: compatible field of inside protocol class
Browse files Browse the repository at this point in the history
  • Loading branch information
jaysunxiao committed Oct 15, 2023
1 parent 8f9897c commit 034f4ac
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ private static String readObject(ProtocolRegistration registration) {
if (field.isAnnotationPresent(Compatible.class)) {
goBuilder.append(TAB ).append("if buffer.CompatibleRead(beforeReadIndex, length) {").append(LS);
var compatibleReadObject = goSerializer(fieldRegistration.serializer()).readObject(goBuilder, 2, field, fieldRegistration);
goBuilder.append(TAB + TAB).append(StringUtils.format("packet.{} = {}", field.getName(), compatibleReadObject)).append(LS);
goBuilder.append(TAB + TAB).append(StringUtils.format("packet.{} = {}", StringUtils.capitalize(field.getName()), compatibleReadObject)).append(LS);
goBuilder.append(TAB).append("}").append(LS);
continue;
}
Expand Down
3 changes: 1 addition & 2 deletions protocol/src/main/resources/go/ByteBuffer.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,7 @@ func (byteBuffer *ByteBuffer) AdjustPadding(predictionLength int, beforeWriteInd
byteBuffer.WriteInt(length)
byteBuffer.SetWriteOffset(currentWriteIndex)
} else {
byteBuffer.SetWriteOffset(currentWriteIndex - length)
var byteArray = byteBuffer.ReadUBytes(length)
var byteArray = byteBuffer.buffer[(currentWriteIndex - length):currentWriteIndex]
byteBuffer.SetWriteOffset(beforeWriteIndex)
byteBuffer.WriteInt(length)
byteBuffer.WriteUBytes(byteArray)
Expand Down

0 comments on commit 034f4ac

Please sign in to comment.