Source:
<code>public static List<LaunchSuite> getLaunchSuites(IJavaProject ijp, ILaunchConfiguration configuration) throws JavaModelException { LaunchType type = ConfigurationHelper.getType(configuration); List<String> packages= null; List<String> testClasses = null; List<String> groups = null; Map<String, List<String>> classMethods= null; if (type == LaunchType.SUITE) { return createLaunchSuites(ijp.getProject(), getSuites(configuration)); } if (type == LaunchType.GROUP) { groups = getGroups(configuration); testClasses = getGroupClasses(configuration); packages= getListAttribute(configuration, TestNGLaunchConfigurationConstants.PACKAGE_TEST_LIST); } else if (type == LaunchType.CLASS) { testClasses = getClasses(configuration); } else if (type == LaunchType.METHOD) { classMethods= getClassMethods(configuration); } else if (type == LaunchType.PACKAGE) { packages= getListAttribute(configuration, TestNGLaunchConfigurationConstants.PACKAGE_TEST_LIST); } List<IJavaElement> je = Lists.newArrayList(); if (packages != null) { for (String pkg : packages) { for (IPackageFragment pf : ijp.getPackageFragments()) { if (pf.getElementName().equals(pkg)) { je.add(pf); break; } } } } if (testClasses != null) { for (String clz : testClasses) { IType t = ijp.findType(clz); if (t != null) { je.add(t); } } } if (classMethods != null) { for (Entry<String, List<String>> entry : classMethods.entrySet()) { IType t = ijp.findType(entry.getKey()); for (String mthd : entry.getValue()) { je.add(t.getMethod(mthd, null)); } } } <START> Map<String, String> parameters= ParameterSolver.solveParameters(je.toArray(new IJavaElement[0])); <END> return createLaunchSuites(ijp.getProject().getName(), packages, testClasses, classMethods, groups, parameters, getLogLevel(configuration) ); }</code><technical_language>je.toArray(new IJavaElement[je.size()]) performance for cost</technical_language>

Target:
public static List<LaunchSuite> getLaunchSuites(IJavaProject ijp, ILaunchConfiguration configuration) throws JavaModelException { LaunchType type = ConfigurationHelper.getType(configuration); List<String> packages= null; List<String> testClasses = null; List<String> groups = null; Map<String, List<String>> classMethods= null; if (type == LaunchType.SUITE) { return createLaunchSuites(ijp.getProject(), getSuites(configuration)); } if (type == LaunchType.GROUP) { groups = getGroups(configuration); testClasses = getGroupClasses(configuration); packages= getListAttribute(configuration, TestNGLaunchConfigurationConstants.PACKAGE_TEST_LIST); } else if (type == LaunchType.CLASS) { testClasses = getClasses(configuration); } else if (type == LaunchType.METHOD) { classMethods= getClassMethods(configuration); } else if (type == LaunchType.PACKAGE) { packages= getListAttribute(configuration, TestNGLaunchConfigurationConstants.PACKAGE_TEST_LIST); } List<IJavaElement> je = Lists.newArrayList(); if (packages != null) { for (String pkg : packages) { for (IPackageFragment pf : ijp.getPackageFragments()) { if (pf.getElementName().equals(pkg)) { je.add(pf); break; } } } } if (testClasses != null) { for (String clz : testClasses) { IType t = ijp.findType(clz); if (t != null) { je.add(t); } } } if (classMethods != null) { for (Entry<String, List<String>> entry : classMethods.entrySet()) { IType t = ijp.findType(entry.getKey()); for (String mthd : entry.getValue()) { je.add(t.getMethod(mthd, null)); } } } Map<String, String> parameters= ParameterSolver.solveParameters(je.toArray(new IJavaElement[je.size()])); return createLaunchSuites(ijp.getProject().getName(), packages, testClasses, classMethods, groups, parameters, getLogLevel(configuration) ); }