Skip to content

Commit 5c80a86

Browse files
committed
Change the param name of configuration to packerSmallStringOptimizationThreshold
1 parent 0dabac5 commit 5c80a86

File tree

2 files changed

+11
-11
lines changed

2 files changed

+11
-11
lines changed

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

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ public static class Config
5050
private final int stringEncoderBufferSize;
5151
private final int stringDecoderBufferSize;
5252
private final int packerBufferSize;
53-
private final int packerLargeStringThreshold;
53+
private final int packerSmallStringOptimizationThreshold; // This parameter is subject to change
5454
private final int packerRawDataCopyingThreshold;
5555

5656
public Config(
@@ -62,7 +62,7 @@ public Config(
6262
int stringEncoderBufferSize,
6363
int stringDecoderBufferSize,
6464
int packerBufferSize,
65-
int packerLargeStringLengthThreshold,
65+
int packerSmallStringOptimizationThreshold,
6666
int packerRawDataCopyingThreshold)
6767
{
6868
checkArgument(packerBufferSize > 0, "packer buffer size must be larger than 0: " + packerBufferSize);
@@ -77,7 +77,7 @@ public Config(
7777
this.stringEncoderBufferSize = stringEncoderBufferSize;
7878
this.stringDecoderBufferSize = stringDecoderBufferSize;
7979
this.packerBufferSize = packerBufferSize;
80-
this.packerLargeStringThreshold = packerLargeStringLengthThreshold;
80+
this.packerSmallStringOptimizationThreshold = packerSmallStringOptimizationThreshold;
8181
this.packerRawDataCopyingThreshold = packerRawDataCopyingThreshold;
8282
}
8383

@@ -136,9 +136,9 @@ public int getPackerBufferSize()
136136
return packerBufferSize;
137137
}
138138

139-
public int getPackerLargeStringLengthThreshold()
139+
public int getPackerSmallStringOptimizationThreshold()
140140
{
141-
return packerLargeStringThreshold;
141+
return packerSmallStringOptimizationThreshold;
142142
}
143143

144144
public int getPackerRawDataCopyingThreshold()
@@ -162,7 +162,7 @@ public static class ConfigBuilder
162162
private int stringEncoderBufferSize = 8192;
163163
private int stringDecoderBufferSize = 8192;
164164
private int packerBufferSize = 8192;
165-
private int packerLargeStringLengthThreshold = 512;
165+
private int packerSmallStringOptimizationThreshold = 512; // This parameter is subject to change
166166
private int packerRawDataCopyingThreshold = 512;
167167

168168
public Config build()
@@ -176,7 +176,7 @@ public Config build()
176176
stringEncoderBufferSize,
177177
stringDecoderBufferSize,
178178
packerBufferSize,
179-
packerLargeStringLengthThreshold,
179+
packerSmallStringOptimizationThreshold,
180180
packerRawDataCopyingThreshold
181181
);
182182
}
@@ -229,9 +229,9 @@ public ConfigBuilder packerBufferSize(int size)
229229
return this;
230230
}
231231

232-
public ConfigBuilder packerLargeStringThreshold(int threshold)
232+
public ConfigBuilder packerSmallStringOptimizationThreshold(int threshold)
233233
{
234-
this.packerLargeStringLengthThreshold = threshold;
234+
this.packerSmallStringOptimizationThreshold = threshold;
235235
return this;
236236
}
237237

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -445,7 +445,7 @@ public MessagePacker packDouble(double v)
445445
private void packSmallString(String s)
446446
throws IOException
447447
{
448-
byte[] bytes = s.getBytes("UTF-8");
448+
byte[] bytes = s.getBytes(MessagePack.UTF8);
449449
packRawStringHeader(bytes.length);
450450
writePayload(bytes);
451451
}
@@ -465,7 +465,7 @@ public MessagePacker packString(String s)
465465
return this;
466466
}
467467

468-
if (s.length() < config.getPackerLargeStringLengthThreshold()) {
468+
if (s.length() < config.getPackerSmallStringOptimizationThreshold()) {
469469
// Write the length and payload of small string to the buffer so that it avoids an extra flush of buffer
470470
packSmallString(s);
471471
return this;

0 commit comments

Comments
 (0)