优化XXXToMapCopier的部分性能(pr#1345@Gitee)

This commit is contained in:
Looly
2025-05-23 21:47:29 +08:00
parent a51da7369d
commit 596cdc2984
2 changed files with 6 additions and 2 deletions

View File

@@ -63,6 +63,9 @@ public class BeanToMapCopier extends AbsCopier<Object, Map> {
actualEditable = copyOptions.editable;
}
// 提前获取目标值真实类型
final Type[] typeArguments = TypeUtil.getTypeArguments(this.targetType);
final Map<String, PropDesc> sourcePropDescMap = getBeanDesc(actualEditable).getPropMap(copyOptions.ignoreCase);
sourcePropDescMap.forEach((sFieldName, sDesc) -> {
if (null == sFieldName || !sDesc.isReadable(copyOptions.transientSupport)) {
@@ -89,7 +92,7 @@ public class BeanToMapCopier extends AbsCopier<Object, Map> {
sValue = entry.getValue();
// 获取目标值真实类型并转换源值
final Type[] typeArguments = TypeUtil.getTypeArguments(this.targetType);
// 尝试转换源值
if(null != typeArguments && typeArguments.length > 1){
//sValue = Convert.convertWithCheck(typeArguments[1], sValue, null, this.copyOptions.ignoreError);
sValue = copyOptions.convertField(typeArguments[1], sValue);

View File

@@ -50,6 +50,8 @@ public class MapToMapCopier extends AbsCopier<Map, Map> {
@Override
public Map copy() {
final Type[] typeArguments = TypeUtil.getTypeArguments(this.targetType);
this.source.forEach((sKey, sValue) -> {
if (null == sKey) {
return;
@@ -74,7 +76,6 @@ public class MapToMapCopier extends AbsCopier<Map, Map> {
}
// 获取目标值真实类型并转换源值
final Type[] typeArguments = TypeUtil.getTypeArguments(this.targetType);
if(null != typeArguments){
sValue = this.copyOptions.convertField(typeArguments[1], sValue);
}