Skip to content

[CODEC-295] Minor improvements#67

Merged
garydgregory merged 1 commit into
apache:masterfrom
arturobernalg:feature/CODEC-295
Dec 13, 2020
Merged

[CODEC-295] Minor improvements#67
garydgregory merged 1 commit into
apache:masterfrom
arturobernalg:feature/CODEC-295

Conversation

@arturobernalg

@arturobernalg arturobernalg commented Dec 7, 2020

Copy link
Copy Markdown
Member

https://issues.apache.org/jira/browse/CODEC-295

Minor improvement

  • extra computations by getting the string size only once.
  • remove unused imports
  • add final String
  • add final method and var
  • FIx javadoc

@coveralls

coveralls commented Dec 7, 2020

Copy link
Copy Markdown

Coverage Status

Coverage increased (+0.2%) to 94.47% when pulling 50f4f72 on arturobernalg:feature/CODEC-295 into d720e87 on apache:master.

@arturobernalg

Copy link
Copy Markdown
Member Author

HI @garydgregory @sebbASF any idea of why the Java CI it's failing?

@garydgregory

Copy link
Copy Markdown
Member

@arturobernalg
Please rebase on master.

final int l = data.length;
final char[] out = new char[l << 1];
encodeHex(data, 0, data.length, toDigits, out, 0);
encodeHex(data, 0, l, toDigits, out, 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.

No mystery names please, especially "l" which can look just like a "1" depending on your font!

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.

agree. fixit

inputs = null;
} else {
inputs = new String[args.length -1];
inputs = new String[argsLength -1];

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.

Formatting.

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.

agree. fixit

if (startsWith && endsWith) {
// exact match
if (content.length() == 0) {
if (contentLength == 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.

Just use String#isEmpty() for 0-length checks on Strings.

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.

agree. fixit

}
};
} else if ((startsWith || endsWith) && content.length() == 0) {
} else if ((startsWith || endsWith) && contentLength == 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.

See above.

*
* @throws IllegalArgumentException for some failure scenarios.
*/
@Test(expected = IllegalArgumentException.class)

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.

Do we need a local var?

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.

agree. fixit

*
* @since 1.17
*/
public class DigestTest{

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.

Fix formatting.

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.

Fix it

@garydgregory garydgregory changed the title [CODEC-295] - Minor improvement [CODEC-295] - Minor improvements Dec 13, 2020
@garydgregory garydgregory merged commit 62d55fd into apache:master Dec 13, 2020
@garydgregory garydgregory changed the title [CODEC-295] - Minor improvements [CODEC-295] Minor improvements Dec 13, 2020
@garydgregory

Copy link
Copy Markdown
Member

@arturobernalg
IMO, we do not need Jira tickets for these kinds of changes.

asfgit pushed a commit that referenced this pull request Dec 13, 2020
omosteven pushed a commit to omosteven/commons-codec-lab-work that referenced this pull request Jan 8, 2025
omosteven pushed a commit to omosteven/commons-codec-lab-work that referenced this pull request Jan 8, 2025
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.

3 participants