Skip to content

Commit c89c32c

Browse files
authored
Merge pull request #731 from ariksher-nex/feature/gen-display-no-alloc
[Java] Avoid memory allocation at varDataDisplay
2 parents 391527a + e6c1b32 commit c89c32c

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

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

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3269,7 +3269,16 @@ private void appendDecoderDisplay(
32693269
}
32703270
else
32713271
{
3272-
append(sb, indent, "builder.append('\\'').append(" + varDataName + "()).append('\\'');");
3272+
if (characterEncoding.contains("ASCII"))
3273+
{
3274+
append(sb, indent, "builder.append('\\'');");
3275+
append(sb, indent, formatGetterName(varDataToken.name()) + "(builder);");
3276+
append(sb, indent, "builder.append('\\'');");
3277+
}
3278+
else
3279+
{
3280+
append(sb, indent, "builder.append('\\'').append(" + varDataName + "()).append('\\'');");
3281+
}
32733282
}
32743283

32753284
lengthBeforeLastGeneratedSeparator = sb.length();

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

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,18 @@ public static String formatPropertyName(final String value)
158158
return formattedValue;
159159
}
160160

161+
/**
162+
* Format a Getter name for generated code.
163+
* <p>
164+
*
165+
* @param value to be formatted.
166+
* @return the string formatted as a getter name.
167+
*/
168+
public static String formatGetterName(final String value)
169+
{
170+
return "get" + Generators.toUpperFirstChar(value);
171+
}
172+
161173
/**
162174
* Format a class name for the generated code.
163175
*

0 commit comments

Comments
 (0)