You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@rocketmq.apache.org by GitBox <gi...@apache.org> on 2022/03/05 12:47:42 UTC

[GitHub] [rocketmq-client-go] ixzk opened a new pull request #783: Maybe can remove some useless code in encodeBatch()

ixzk opened a new pull request #783:
URL: https://github.com/apache/rocketmq-client-go/pull/783


   I streamlined the code of the encodeBatch() method and removed the else branch. The reasons are as follows:
   The first line of encodeBatch() judges the case where len == 1. According to the judgment condition of if, else should take effect when len < 1 (ie len == 0). But the case of len == 0 is judged by checkMsg() before using the encodeBatch() method. Personally think that encodeBatch can be simplified.
   Of course, the original author may need to keep the else branch from the perspective of code specifications or language features.
   
   我精简了encodeBatch()方法的代码,删除了else分支。原因如下:
   encodeBatch()第一行判断了 len == 1的情况。根据if的判断条件,else应该是len < 1时生效(即len == 0)。 但在使用encodeBatch()方法之前通过checkMsg()判断了len == 0的情况。 个人认为可以精简encodeBatch。
   当然,原作者可能从代码规范或者语言特性方面考虑,需要保留else分支。


-- 
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: dev-unsubscribe@rocketmq.apache.org

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