This pull request refactors the trimAllWhitespace(CharSequence) method to improve code readability and performance. The following changes have been made:
- Stream API Adoption: Replaced the manual iteration over characters with Java 8's Stream API for a more declarative and concise approach.
- Performance Improvement: Using
chars()
combined with filtering reduces the overhead of managing character-by-character logic manually, leading to better performance in modern Java environments. - Code Simplification: Removed the explicit loop and
StringBuilder
usage, opting for a more functional approach to enhance maintainability and reduce boilerplate.
Comment From: pivotal-cla
@SungbinYang Please sign the Contributor License Agreement!
Click here to manually synchronize the status of this Pull Request.
See the FAQ for frequently asked questions.
Comment From: pivotal-cla
@SungbinYang Thank you for signing the Contributor License Agreement!
Comment From: bclozel
Thanks but we tend to avoid Stream
usage in hot code paths where it can lead to performance degradation.
Comment From: SungbinYang
Rather, I am more grateful. If I see something that can contribute, I will upload the PR again.