Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Enhancement] 方法DefaultLitePullConsumerImpl#isSetEqual可以优化 #8090

Closed
1 task done
Willhow-Gao opened this issue May 3, 2024 · 0 comments · Fixed by #8091
Closed
1 task done

[Enhancement] 方法DefaultLitePullConsumerImpl#isSetEqual可以优化 #8090

Willhow-Gao opened this issue May 3, 2024 · 0 comments · Fixed by #8091

Comments

@Willhow-Gao
Copy link
Contributor

Before Creating the Enhancement Request

  • I have confirmed that this should be classified as an enhancement rather than a bug/feature.

Summary

  1. 方法isSetEqual在比较两个set时,两个set都为empty时,返回的是不相等,从逻辑上来说,应该是true吧,毕竟两个set都为null判定的都是相等。从代码上说,从broker获取topic的messagequeue不可能是空的,否则会抛MQClientException异常。因此我认为应该移除掉set1.size()==0这个判断。
image image image 2. 当已经找到了一个set1中存在,但是set2中不存在的元素时,就可以判定两个set不相等了,直接退出循环即可,没必要再继续比较了 image

Motivation

优化isSetEqual以提高方法性能

Describe the Solution You'd Like

  1. 移除错误且不必要的分支判断set1.size() == 0
  2. 检测到不相等元素时,提前退出循环并返回结果

Describe Alternatives You've Considered

Additional Context

No response

Willhow-Gao added a commit to Willhow-Gao/rocketmq that referenced this issue May 3, 2024
RongtongJin pushed a commit that referenced this issue May 8, 2024
)

* [ISSUE #8090]1.optimize isSetEqual method and add Unit tests; 2.fix a typo in MQAdminImpl

* remove author message

* Modify code style
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant