Skip to content

Commit d79b6ef

Browse files
committed
Packer -> MessagePacker
1 parent 8a547a6 commit d79b6ef

16 files changed

Lines changed: 47 additions & 46 deletions

msgpack-core/src/main/java/org/msgpack/core/MessageBuffer.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,12 @@
1313
import static sun.misc.Unsafe.ARRAY_BYTE_INDEX_SCALE;
1414

1515
/**
16-
* MessageBuffer class is an abstraction of memory for reading/writing message pac data.
17-
* This MessageBuffers ensures integers (31-bit singed) are written to the memory in big-endian order.
16+
* MessageBuffer class is an abstraction of memory for reading/writing message packed data.
17+
* This MessageBuffers ensures integers (31-bit singed) are written in the big-endian order.
1818
*
1919
* This class is optimized for fast memory access, so many methods are
20-
* implemented without using any interface method that produces invokeinterface call in JVM, which is generally
21-
* 30% slower than invokevirtual, because invokeinterface needs to look up a function from the function table.
20+
* implemented without using any interface method that produces invokeinterface call in JVM.
21+
* Compared to invokevirtual, invokeinterface is 30% slower in general because it needs to find a target function from the table.
2222
*
2323
*/
2424
public class MessageBuffer {

msgpack-value/src/main/java/org/msgpack/value/impl/AbstractImmutableRawValue.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
import org.msgpack.value.ImmutableRawValue;
2828
import org.msgpack.value.MessageTypeStringCodingException;
2929
import org.msgpack.core.ValueType;
30-
import org.msgpack.core.Packer;
30+
import org.msgpack.core.MessagePacker;
3131

3232
abstract class AbstractImmutableRawValue
3333
extends AbstractImmutableValue implements ImmutableRawValue {

msgpack-value/src/main/java/org/msgpack/value/impl/ImmutableArrayMapValueImpl.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
import org.msgpack.value.ImmutableExtendedValue;
4343
import org.msgpack.value.MessageTypeCastException;
4444
import org.msgpack.core.ValueType;
45-
import org.msgpack.core.Packer;
45+
import org.msgpack.core.MessagePacker;
4646

4747
public class ImmutableArrayMapValueImpl
4848
extends AbstractMap<Value, Value> implements ImmutableMapValue {
@@ -213,8 +213,8 @@ public Collection<Value> values() {
213213
}
214214

215215
@Override
216-
public void writeTo(Packer pk) throws IOException {
217-
pk.writeMapHeader(array.length / 2);
216+
public void writeTo(MessagePacker pk) throws IOException {
217+
pk.packMapHeader(array.length / 2);
218218
for (int i = 0; i < array.length; i++) {
219219
array[i].writeTo(pk);
220220
}

msgpack-value/src/main/java/org/msgpack/value/impl/ImmutableArrayValueImpl.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
import org.msgpack.value.ImmutableExtendedValue;
3535
import org.msgpack.value.MessageTypeCastException;
3636
import org.msgpack.core.ValueType;
37-
import org.msgpack.core.Packer;
37+
import org.msgpack.core.MessagePacker;
3838

3939
public class ImmutableArrayValueImpl
4040
extends AbstractList<Value> implements ImmutableArrayValue {
@@ -56,8 +56,8 @@ public ValueType getType() {
5656
}
5757

5858
@Override
59-
public void writeTo(Packer pk) throws IOException {
60-
pk.writeArrayHeader(array.length);
59+
public void writeTo(MessagePacker pk) throws IOException {
60+
pk.packArrayHeader(array.length);
6161
for (int i = 0; i < array.length; i++) {
6262
array[i].writeTo(pk);
6363
}

msgpack-value/src/main/java/org/msgpack/value/impl/ImmutableBigIntegerValueImpl.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
import org.msgpack.value.ImmutableIntegerValue;
2424
import org.msgpack.value.MessageTypeIntegerOverflowException;
2525
import org.msgpack.core.ValueType;
26-
import org.msgpack.core.Packer;
26+
import org.msgpack.core.MessagePacker;
2727

2828
public class ImmutableBigIntegerValueImpl
2929
extends AbstractImmutableValue implements ImmutableIntegerValue {
@@ -147,8 +147,8 @@ public boolean isInLongRange() {
147147
}
148148

149149
@Override
150-
public void writeTo(Packer pk) throws IOException {
151-
pk.writeBigInteger(value);
150+
public void writeTo(MessagePacker pk) throws IOException {
151+
pk.packBigInteger(value);
152152
}
153153

154154
@Override

msgpack-value/src/main/java/org/msgpack/value/impl/ImmutableBinaryValueImpl.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
import org.msgpack.value.BinaryValue;
2727
import org.msgpack.value.ImmutableBinaryValue;
2828
import org.msgpack.core.ValueType;
29-
import org.msgpack.core.Packer;
29+
import org.msgpack.core.MessagePacker;
3030

3131
public class ImmutableBinaryValueImpl
3232
extends AbstractImmutableRawValue implements ImmutableBinaryValue {
@@ -40,9 +40,9 @@ public ValueType getType() {
4040
}
4141

4242
@Override
43-
public void writeTo(Packer pk) throws IOException {
44-
pk.writeBinaryLength(byteBuffer.remaining());
45-
pk.rawWrite(byteBuffer.asReadOnlyBuffer());
43+
public void writeTo(MessagePacker pk) throws IOException {
44+
pk.packBinaryHeader(byteBuffer.remaining());
45+
pk.writePayload(byteBuffer.asReadOnlyBuffer());
4646
}
4747

4848
@Override

msgpack-value/src/main/java/org/msgpack/value/impl/ImmutableDoubleValueImpl.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
import org.msgpack.value.Value;
2323
import org.msgpack.value.ImmutableFloatValue;
2424
import org.msgpack.core.ValueType;
25-
import org.msgpack.core.Packer;
25+
import org.msgpack.core.MessagePacker;
2626

2727
public class ImmutableDoubleValueImpl
2828
extends AbstractImmutableValue implements ImmutableFloatValue {
@@ -88,8 +88,8 @@ public boolean equals(Object o) {
8888
}
8989

9090
@Override
91-
public void writeTo(Packer pk) throws IOException {
92-
pk.writeDouble(value);
91+
public void writeTo(MessagePacker pk) throws IOException {
92+
pk.packDouble(value);
9393
}
9494

9595
@Override

msgpack-value/src/main/java/org/msgpack/value/impl/ImmutableFalseValueImpl.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
import org.msgpack.value.Value;
2121
import org.msgpack.value.ImmutableBooleanValue;
2222
import org.msgpack.core.ValueType;
23-
import org.msgpack.core.Packer;
23+
import org.msgpack.core.MessagePacker;
2424

2525
public class ImmutableFalseValueImpl
2626
extends AbstractImmutableValue implements ImmutableBooleanValue {
@@ -50,8 +50,8 @@ public boolean booleanValue() {
5050
}
5151

5252
@Override
53-
public void writeTo(Packer pk) throws IOException {
54-
pk.writeBoolean(false);
53+
public void writeTo(MessagePacker pk) throws IOException {
54+
pk.packBoolean(false);
5555
}
5656

5757
@Override

msgpack-value/src/main/java/org/msgpack/value/impl/ImmutableFloatValueImpl.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
import org.msgpack.value.Value;
2323
import org.msgpack.value.ImmutableFloatValue;
2424
import org.msgpack.core.ValueType;
25-
import org.msgpack.core.Packer;
25+
import org.msgpack.core.MessagePacker;
2626

2727
public class ImmutableFloatValueImpl
2828
extends AbstractImmutableValue implements ImmutableFloatValue {
@@ -88,8 +88,8 @@ public boolean equals(Object o) {
8888
}
8989

9090
@Override
91-
public void writeTo(Packer pk) throws IOException {
92-
pk.writeFloat(value);
91+
public void writeTo(MessagePacker pk) throws IOException {
92+
pk.packFloat(value);
9393
}
9494

9595
@Override

msgpack-value/src/main/java/org/msgpack/value/impl/ImmutableIntValueImpl.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
import org.msgpack.value.ImmutableIntegerValue;
2424
import org.msgpack.value.MessageTypeIntegerOverflowException;
2525
import org.msgpack.core.ValueType;
26-
import org.msgpack.core.Packer;
26+
import org.msgpack.core.MessagePacker;
2727

2828
public class ImmutableIntValueImpl
2929
extends AbstractImmutableValue implements ImmutableIntegerValue {
@@ -136,8 +136,8 @@ public boolean isInLongRange() {
136136
}
137137

138138
@Override
139-
public void writeTo(Packer pk) throws IOException {
140-
pk.writeInt(value);
139+
public void writeTo(MessagePacker pk) throws IOException {
140+
pk.packInt(value);
141141
}
142142

143143
@Override

0 commit comments

Comments
 (0)