Skip to content

[SCB-1528] Optimizing some code implementations#1353

Merged
yhs0092 merged 1 commit intoapache:masterfrom
AngLi2:optimize
Oct 23, 2019
Merged

[SCB-1528] Optimizing some code implementations#1353
yhs0092 merged 1 commit intoapache:masterfrom
AngLi2:optimize

Conversation

@AngLi2
Copy link
Copy Markdown
Contributor

@AngLi2 AngLi2 commented Oct 16, 2019

Follow this checklist to help us incorporate your contribution quickly and easily:

  • Make sure there is a JIRA issue filed for the change (usually before you start working on it). Trivial changes like typos do not require a JIRA issue. Your pull request should address just this issue, without pulling in other changes.
  • Each commit in the pull request should have a meaningful subject line and body.
  • Format the pull request title like [SCB-XXX] Fixes bug in ApproximateQuantiles, where you replace SCB-XXX with the appropriate JIRA issue.
  • Write a pull request description that is detailed enough to understand what the pull request does, how, and why.
  • Run mvn clean install -Pit to make sure basic checks pass. A more thorough check will be performed on your pull request automatically.
  • If this contribution is large, please file an Apache Individual Contributor License Agreement.

@AngLi2
Copy link
Copy Markdown
Contributor Author

AngLi2 commented Oct 16, 2019

  1. Iterating entrySet() is more efficent than entryKey() when call map.get(key) each time;
  2. Collections.isEmpty() is more efficent than collections.size() == 0
  3. Util classes should have private constructures
  4. String.valueOf() is more efficent then + ""
  5. BigDecimal() may cause some precision problems while BigDecimal.valueOf() not
  6. Return empty collection instead of null can prevent NPE
  7. Objects.equals(a, b) is better than a.equals(b) because of NPE
  8. Data in enum shoud be private final

@AngLi2 AngLi2 closed this Oct 16, 2019
@AngLi2 AngLi2 reopened this Oct 17, 2019
public void onBootEvent(BootEvent bootEvent) {
if (bootEvent.getEventType() == EventType.BEFORE_REGISTRY) {
MicroserviceVersionRule rule = RegistryUtils.getServiceRegistry().getAppManager()
.getOrCreateMicroserviceVersionRule(RegistryUtils.getAppId(), "it-producer", "0+");
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This test case is useful that we must gurrantee we can call getOrCreateMicroserviceVersionRule after BEFORE_REGISTRY without exception throw in bootup.

@AngLi2 AngLi2 force-pushed the optimize branch 2 times, most recently from b8184ba to ae891fb Compare October 17, 2019 11:10
@coveralls
Copy link
Copy Markdown

coveralls commented Oct 17, 2019

Coverage Status

Coverage decreased (-0.006%) to 85.874% when pulling 90299b2 on AngLi2:optimize into 4595644 on apache:master.

LOGGER.warn("Prefetch not successful, maybe the provider not started.");
}
@Override
public void onBootEvent(BootEvent bootEvent) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

It seems this code does not use servicecomb recommented formatter.

@yhs0092 yhs0092 merged commit ab1783a into apache:master Oct 23, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants