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

optimize: simplify if else judgment #3939

Merged
merged 10 commits into from
Sep 14, 2021
Merged

Conversation

coconut4j
Copy link
Contributor

Ⅰ. Describe what this PR did

use two ImmutableMap instead of lots of if else judge, and the code is more readability,more convenient to modify.

Ⅱ. Does this pull request fix one issue?

切换develop分支 以及将map并入构造器 旧pr #3932

Ⅲ. Why don't you add test cases (unit test/integration test)?

Ⅳ. Describe how to verify it

Ⅴ. Special notes for reviews

@caohdgege
Copy link
Contributor

can the DatabaseTransactionStoreManager be optimize like this?

@coconut4j
Copy link
Contributor Author

can the DatabaseTransactionStoreManager be optimize like this?
DataBaseTransactionStoreManager can use one map to solve it

@slievrly slievrly added first-time contributor first-time contributor module/server server module TC/store store mode labels Aug 13, 2021
Copy link
Contributor

@l81893521 l81893521 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Contributor

@l81893521 l81893521 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you put some change log in change module like other PR?

@coconut4j
Copy link
Contributor Author

Can you put some change log in change module like other PR?

ok,i finished it

Copy link
Contributor

@funky-eyes funky-eyes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@codecov-commenter
Copy link

codecov-commenter commented Aug 17, 2021

Codecov Report

Merging #3939 (9063d47) into develop (129c2f3) will decrease coverage by 9.23%.
The diff coverage is 0.00%.

❗ Current head 9063d47 differs from pull request most recent head 9e03023. Consider uploading reports for the commit 9e03023 to get more accurate results
Impacted file tree graph

@@              Coverage Diff              @@
##             develop    #3939      +/-   ##
=============================================
- Coverage      49.59%   40.35%   -9.24%     
+ Complexity      3730     3072     -658     
=============================================
  Files            693      685       -8     
  Lines          23402    23203     -199     
  Branches        2899     2864      -35     
=============================================
- Hits           11606     9364    -2242     
- Misses         10631    12969    +2338     
+ Partials        1165      870     -295     
Impacted Files Coverage Δ
...rage/redis/store/RedisTransactionStoreManager.java 0.00% <0.00%> (-63.64%) ⬇️
.../java/io/seata/server/transaction/tcc/TccCore.java 0.00% <0.00%> (-100.00%) ⬇️
...java/io/seata/server/metrics/MeterIdConstants.java 0.00% <0.00%> (-100.00%) ⬇️
.../io/seata/server/session/BranchSessionHandler.java 0.00% <0.00%> (-100.00%) ⬇️
.../io/seata/server/store/DbcpDataSourceProvider.java 0.00% <0.00%> (-100.00%) ⬇️
...io/seata/server/store/DruidDataSourceProvider.java 0.00% <0.00%> (-100.00%) ⬇️
...o/seata/server/store/HikariDataSourceProvider.java 0.00% <0.00%> (-100.00%) ⬇️
...ack/ExtendedWhitespaceThrowableProxyConverter.java 0.00% <0.00%> (-100.00%) ⬇️
...java/io/seata/server/storage/SessionConverter.java 0.00% <0.00%> (-94.65%) ⬇️
...ver/lock/distributed/DistributedLockerFactory.java 0.00% <0.00%> (-89.48%) ⬇️
... and 92 more

changes/en-us/1.5.0.md Outdated Show resolved Hide resolved
Comment on lines +154 to +157
if (globalMap.containsKey(logOperation) || branchMap.containsKey(logOperation)) {
return globalMap.containsKey(logOperation) ?
globalMap.get(logOperation).apply(SessionConverter.convertGlobalTransactionDO(session)) :
branchMap.get(logOperation).apply(SessionConverter.convertBranchTransactionDO(session));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In my opinion,there is no need to invoke globalMap.containsKey(logOperation) again.it is better to break the if statement into two if statements.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1

Copy link
Contributor

@funky-eyes funky-eyes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

为何不把db那块实现一并修改?

Copy link
Member

@slievrly slievrly left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@lgtm-com
Copy link

lgtm-com bot commented Sep 14, 2021

This pull request introduces 2 alerts when merging 9e03023 into 129c2f3 - view on LGTM.com

new alerts:

  • 2 for Spurious Javadoc @param tags

@slievrly slievrly changed the title optimize:use map instead of if else judge for more change in the future optimize: simplify if else judgment Sep 14, 2021
@slievrly slievrly merged commit 207b09d into apache:develop Sep 14, 2021
@slievrly slievrly added this to the 1.5.0 milestone Sep 14, 2021
UmmizzZ pushed a commit to UmmizzZ/seata that referenced this pull request Sep 30, 2021
@coconut4j coconut4j deleted the prseata branch December 17, 2021 02:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
first-time contributor first-time contributor module/server server module TC/store store mode
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants