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

重构反射工厂,优化字段映射的处理效率 #232

Closed
Createsequence opened this issue Mar 15, 2024 · 0 comments
Closed

重构反射工厂,优化字段映射的处理效率 #232

Createsequence opened this issue Mar 15, 2024 · 0 comments
Assignees
Labels
primary This is an important feature or fix that needs to be completed as a top priority refactor Refactoring code to optimize or add functionality
Milestone

Comments

@Createsequence
Copy link
Collaborator

Createsequence commented Mar 15, 2024

目前 crane4j 在装配处理器中进行属性映射的时候,会使用反射工厂 PropertyOperator 的 write/read 方法获取/写入属性值,在这个过程中,每一次读写都需要进行 “找到目标类属性缓存-从属性缓存中找到具体的方法缓存”。由于框架中所有的反射都需要经过次过程,这带来了额外的性能开销。

在 2.7.0 版本中,考虑参照 Mybatis 的反射工厂的实现方式,将整个过程分为两步:

  • 先根据目标类型获取反射对象;
  • 从反射对象中根据属性获取具体的操作方法;

其中,对应属性映射这种“针对同一类型进行大量属性操作”的场景下,可以避免重复第一个步骤。

@Createsequence Createsequence added refactor Refactoring code to optimize or add functionality primary This is an important feature or fix that needs to be completed as a top priority labels Mar 15, 2024
@Createsequence Createsequence self-assigned this Mar 15, 2024
@Createsequence Createsequence added this to the release 2.7.0 milestone Mar 15, 2024
@Createsequence Createsequence changed the title 优化反射调用效率 重构反射工厂,优化字段映射的处理效率 Mar 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
primary This is an important feature or fix that needs to be completed as a top priority refactor Refactoring code to optimize or add functionality
Projects
None yet
Development

No branches or pull requests

1 participant