mirror of
https://github.com/tiennm99/zfoo.git
synced 2026-08-20 00:24:06 +00:00
perf[golang]: compatible field of inside protocol class
This commit is contained in:
@@ -192,7 +192,7 @@ public abstract class GenerateGoUtils {
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user