You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by GitBox <gi...@apache.org> on 2021/12/15 03:01:55 UTC

[GitHub] [pulsar] BewareMyPower commented on pull request #13293: [Issue 13285][pulsar-client] Optimize MessageBuilder and SharedBuffer to avoid unnecessary memory copy.

BewareMyPower commented on pull request #13293:
URL: https://github.com/apache/pulsar/pull/13293#issuecomment-994245553


   I have a suggestion for testing the memory copy doesn't occur after this change, but it might depend on the implementation of `std::string`.
   
   ```c++
   TEST(MessageBuilderTest, testSetContent) {
       std::string value;
       value.resize(1024, 'x');
       const void* originalAddress = &value[0];
       {
           auto msg = MessageBuilder().setContent(value).build();
           ASSERT_NE(msg.getData(), originalAddress);
       }
       {
           auto msg = MessageBuilder().setContent(std::move(value)).build();
           ASSERT_EQ(msg.getData(), originalAddress);
       }
   }
   ```


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@pulsar.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org