Skip to content

Commit 04d7b0f

Browse files
committed
[Java] Efficiency improvements to display decoder.
1 parent 35705ca commit 04d7b0f

File tree

4 files changed

+6
-5
lines changed

4 files changed

+6
-5
lines changed

sbe-samples/src/main/resources/example-extension-schema.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@
6565
<group name="fuelFigures" id="10" dimensionType="groupSizeEncoding">
6666
<field name="speed" id="11" type="uint16"/>
6767
<field name="mpg" id="12" type="float"/>
68-
<data name="usageDescription" id="200" type="varStringEncoding"/>
68+
<data name="usageDescription" id="200" type="varAsciiEncoding"/>
6969
</group>
7070
<group name="performanceFigures" id="13" dimensionType="groupSizeEncoding">
7171
<field name="octaneRating" id="14" type="Ron"/>

sbe-samples/src/main/resources/example-schema.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@
6161
<group name="fuelFigures" id="10" dimensionType="groupSizeEncoding">
6262
<field name="speed" id="11" type="uint16"/>
6363
<field name="mpg" id="12" type="float"/>
64-
<data name="usageDescription" id="200" type="varStringEncoding"/>
64+
<data name="usageDescription" id="200" type="varAsciiEncoding"/>
6565
</group>
6666
<group name="performanceFigures" id="13" dimensionType="groupSizeEncoding">
6767
<field name="octaneRating" id="14" type="Ron"/>

sbe-tool/src/main/java/uk/co/real_logic/sbe/generation/java/JavaGenerator.java

+2-1
Original file line numberDiff line numberDiff line change
@@ -3203,6 +3203,7 @@ private void appendGroupInstanceDecoderDisplay(
32033203
Separators.BEGIN_COMPOSITE.appendToGeneratedBuilder(sb, indent + INDENT, "builder");
32043204
appendDecoderDisplay(sb, fields, groups, varData, indent + INDENT);
32053205
Separators.END_COMPOSITE.appendToGeneratedBuilder(sb, indent + INDENT, "builder");
3206+
sb.append('\n');
32063207
append(sb, indent, " return builder;");
32073208
append(sb, indent, "}");
32083209
}
@@ -3383,7 +3384,7 @@ private void appendToString(final StringBuilder sb, final String indent)
33833384
sb.append('\n');
33843385
append(sb, indent, "public String toString()");
33853386
append(sb, indent, "{");
3386-
append(sb, indent, " return appendTo(new StringBuilder(100)).toString();");
3387+
append(sb, indent, " return appendTo(new StringBuilder()).toString();");
33873388
append(sb, indent, "}");
33883389
}
33893390
}

sbe-tool/src/main/java/uk/co/real_logic/sbe/generation/java/JavaUtil.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -58,15 +58,15 @@ public enum Separators
5858
}
5959

6060
/**
61-
* Add separator to a generated StringBuilder
61+
* Add separator to a generated append to a {@link StringBuilder}.
6262
*
6363
* @param builder the code generation builder to which information should be added
6464
* @param indent the current generated code indentation
6565
* @param builderName of the generated StringBuilder to which separator should be added
6666
*/
6767
public void appendToGeneratedBuilder(final StringBuilder builder, final String indent, final String builderName)
6868
{
69-
append(builder, indent, builderName + ".append('" + symbol + "');");
69+
builder.append(indent).append(builderName).append(".append('").append(symbol).append("');").append('\n');
7070
}
7171

7272
public String toString()

0 commit comments

Comments
 (0)