优化 toArray 预设大小的数组替换为零长度数组

This commit is contained in:
thinkgem
2025-08-14 21:52:00 +08:00
parent 7f77715cc0
commit 65aa023c92
3 changed files with 3 additions and 3 deletions

View File

@@ -41,7 +41,7 @@ public class PostListType implements FieldType {
}
}
}
return list.size() > 0 ? list.toArray(new String[list.size()]) : null;
return !list.isEmpty() ? list.toArray(new String[0]) : null;
}
/**

View File

@@ -41,7 +41,7 @@ public class RoleListType implements FieldType {
}
}
}
return list.size() > 0 ? list.toArray(new String[list.size()]) : null;
return !list.isEmpty() ? list.toArray(new String[0]) : null;
}
/**

View File

@@ -263,7 +263,7 @@ public class EmpUtils {
}
}
});
return list.toArray(new String[list.size()]);
return list.toArray(new String[0]);
}
/**