Skip to content

Minor Improvement:#247

Merged
ok2c merged 1 commit intoapache:masterfrom
arturobernalg:feature/minor_improvements
Jan 26, 2021
Merged

Minor Improvement:#247
ok2c merged 1 commit intoapache:masterfrom
arturobernalg:feature/minor_improvements

Conversation

@arturobernalg
Copy link
Copy Markdown
Member

  • Use Empty collections
  • Unnecessary boxing
  • Unnecessary toString
  • Use Math.max

/**
* An empty immutable {@code NameValuePair} array.
*/
public static final NameValuePair[] EMPTY_NAME_VALUE_PAIR_ARRAY = new NameValuePair[0];
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@arturobernalg There is no need to make it public. Please change to private.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Ok. changed

@arturobernalg arturobernalg force-pushed the feature/minor_improvements branch from 89d67d5 to 7fc219c Compare January 25, 2021 19:16
@arturobernalg arturobernalg requested a review from ok2c January 25, 2021 19:27
Copy link
Copy Markdown
Member Author

@arturobernalg arturobernalg left a comment

Choose a reason for hiding this comment

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

Changed

/**
* An empty immutable {@code NameValuePair} array.
*/
public static final NameValuePair[] EMPTY_NAME_VALUE_PAIR_ARRAY = new NameValuePair[0];
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Ok. changed


return new HttpServer(
this.listenerPort > 0 ? this.listenerPort : 0,
Math.max(this.listenerPort, 0),
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@arturobernalg What are benefits of using Math#max here? Is it more byte code efficient? I am kind of old and stupid. It makes it more difficult for me to understand the intent of the operation. I am also a bit worried that the proposed code appears to make no distinction between greater and greater equal (as well lesser and lesser equal) comparison operations.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

@arturobernalg What are benefits of using Math#max here? Is it more byte code efficient? I am kind of old and stupid. It makes it more difficult for me to understand the intent of the operation. I am also a bit worried that the proposed code appears to make no distinction between greater and greater equal (as well lesser and lesser equal) comparison operations.

HI @ok2c
My idea was get more readability. As far as I know for implementation/performance sake, they would be nearly equivalent. Maybe a bit more faster the java implementations. But your right, no make no distinction between greater and greater equal. I gonna remove that changes.

* Use Empty collections
* Unnecessary boxing
* Unnecessary toString
@arturobernalg arturobernalg force-pushed the feature/minor_improvements branch from 99507c3 to 168907d Compare January 26, 2021 05:34
@ok2c ok2c merged commit edcf8c9 into apache:master Jan 26, 2021
@arturobernalg arturobernalg deleted the feature/minor_improvements branch February 5, 2021 07:00
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.

2 participants