Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

改进部分代码细节,提高运行性能 #6593

Open
wants to merge 4 commits into
base: 3.0
Choose a base branch
from

Conversation

CodePlayer
Copy link

主要改进内容:

  1. 使用自定义方法替换部分 String.formart() 方法,优化字符串拼接性能(建议尽量不要使用 String.format() 进行字符串拼接 )。
  2. 改进部分工具方法,提升处理性能。比如将 replaceAll("\\.", replacement) 替换为 replace(".", replacement) (避免不必要的正则表达式替换开销)。
  3. 精简部分不必要的 Lambda 表达式,提高运行性能(每一个 Lambda 表达式,在每次调用时本质上都是 new 一个匿名类。 除非确实能够比较优雅地减少代码量,否则建议在使用 Lambda 时尽量保持克制,以降低运行开销。更不建议在不能减少代码量的情况下,为了 Lambda 而 Lambda 。大多数情况下,都可以通过提前封装好工具方法,来实现更少的代码量,并且性能也会有一定提升,如果优化得当,还可以提升数倍)。

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.

1 participant