Skip to content

Optimizing StringDisplayUtils.trimDisplayLength - #104

Merged
ctongfei merged 1 commit into
ctongfei:mainfrom
heroesleo65:StringDisplayUtilsOptimization
Jul 1, 2021
Merged

ctongfei merged 1 commit into
ctongfei:mainfrom
heroesleo65:StringDisplayUtilsOptimization

Conversation

@heroesleo65

Copy link
Copy Markdown
Contributor

I found three problems in implementation of StringDisplayUtils.trimDisaplyLength:

  1. Using StringBuilder for getting substring (String.substring is recommend for using)
  2. Double check on totalLength: "totalLength < maxDisplayLength"
  3. Code can get StringIndexOutOfBoundsException, because you don't have check on length of string

@ctongfei
ctongfei merged commit a3eefed into ctongfei:main Jul 1, 2021
@ctongfei

ctongfei commented Jul 1, 2021

Copy link
Copy Markdown
Owner

Thanks @heroesleo65 ! This is great.

@heroesleo65
heroesleo65 deleted the StringDisplayUtilsOptimization branch July 4, 2021 20:10
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