@@ -352,7 +352,10 @@ private void generateGroupDecoderClassHeader(
352352 indent + " final %s parentMessage, final %s buffer)\n " +
353353 indent + " {\n " +
354354 indent + " this.parentMessage = parentMessage;\n " +
355- indent + " this.buffer = buffer;\n " +
355+ indent + " if (buffer != this.buffer)\n " +
356+ indent + " {\n " +
357+ indent + " this.buffer = buffer;\n " +
358+ indent + " }\n " +
356359 indent + " dimensions.wrap(buffer, parentMessage.limit());\n " +
357360 indent + " blockLength = (int)dimensions.blockLength();\n " +
358361 indent + " count = (int)dimensions.numInGroup();\n " +
@@ -444,7 +447,10 @@ private void generateGroupEncoderClassHeader(
444447 ind + " throw new IllegalArgumentException(\" count outside allowed range: count=\" + count);\n " +
445448 ind + " }\n \n " +
446449 ind + " this.parentMessage = parentMessage;\n " +
447- ind + " this.buffer = buffer;\n " +
450+ ind + " if (buffer != this.buffer)\n " +
451+ ind + " {\n " +
452+ ind + " this.buffer = buffer;\n " +
453+ ind + " }\n " +
448454 ind + " dimensions.wrap(buffer, parentMessage.limit());\n " +
449455 ind + " dimensions.blockLength((%5$s)%6$d);\n " +
450456 ind + " dimensions.numInGroup((%7$s)count);\n " +
@@ -2236,7 +2242,10 @@ private CharSequence generateFixedFlyweightCode(
22362242 " private %3$s buffer;\n \n " +
22372243 " public %1$s wrap(final %3$s buffer, final int offset)\n " +
22382244 " {\n " +
2239- " this.buffer = buffer;\n " +
2245+ " if (buffer != this.buffer)\n " +
2246+ " {\n " +
2247+ " this.buffer = buffer;\n " +
2248+ " }\n " +
22402249 " this.offset = offset;\n \n " +
22412250 " return this;\n " +
22422251 " }\n \n " +
@@ -2276,7 +2285,10 @@ private CharSequence generateDecoderFlyweightCode(final String className, final
22762285 " public %1$s wrap(\n " +
22772286 " final %2$s buffer, final int offset, final int actingBlockLength, final int actingVersion)\n " +
22782287 " {\n " +
2279- " this.buffer = buffer;\n " +
2288+ " if (buffer != this.buffer)\n " +
2289+ " {\n " +
2290+ " this.buffer = buffer;\n " +
2291+ " }\n " +
22802292 " this.offset = offset;\n " +
22812293 " this.actingBlockLength = actingBlockLength;\n " +
22822294 " this.actingVersion = actingVersion;\n " +
@@ -2381,7 +2393,10 @@ private CharSequence generateEncoderFlyweightCode(final String className, final
23812393 final String wrapMethod = String .format (
23822394 " public %1$s wrap(final %2$s buffer, final int offset)\n " +
23832395 " {\n " +
2384- " this.buffer = buffer;\n " +
2396+ " if (buffer != this.buffer)\n " +
2397+ " {\n " +
2398+ " this.buffer = buffer;\n " +
2399+ " }\n " +
23852400 " this.offset = offset;\n " +
23862401 " limit(offset + BLOCK_LENGTH);\n \n " +
23872402 " return this;\n " +
0 commit comments