Skip to content

util: Return empty string directly if the byte slice is empty#11828

Closed
suzaku wants to merge 3 commits intopingcap:masterfrom
suzaku:return-early
Closed

util: Return empty string directly if the byte slice is empty#11828
suzaku wants to merge 3 commits intopingcap:masterfrom
suzaku:return-early

Conversation

@suzaku
Copy link
Contributor

@suzaku suzaku commented Aug 22, 2019

What problem does this PR solve?

When the input is empty, it's faster to just return an empty string.

What is changed and how it works?

Return an empty string directly if the input is empty.

Check List

Tests

  • Unit test

Code changes

Side effects

Related changes

@codecov
Copy link

codecov bot commented Aug 22, 2019

Codecov Report

Merging #11828 into master will decrease coverage by 0.1595%.
The diff coverage is 100%.

@@               Coverage Diff                @@
##             master     #11828        +/-   ##
================================================
- Coverage   81.5904%   81.4308%   -0.1596%     
================================================
  Files           435        435                
  Lines         94630      94129       -501     
================================================
- Hits          77209      76650       -559     
- Misses        11925      11980        +55     
- Partials       5496       5499         +3

Copy link
Member

@zz-jason zz-jason left a comment

Choose a reason for hiding this comment

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

Users may wish to change the content of the underlying []byte by modifying the returned string. So I think this change is not applicable for this situation.

Copy link
Member

@zz-jason zz-jason left a comment

Choose a reason for hiding this comment

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

Users may wish to change the content of the underlying []byte by modifying the returned string. So I think this change is not applicable for this situation.

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