Kaydet (Commit) 02ace92a authored tarafından Noel Grandin's avatar Noel Grandin

java: optimise calls to toArray

passing in a correctly sized array requires one less allocation

Change-Id: I6198d226d9b630c99c4e8b6e3d0fdf890c495b44
üst 04ace01e
......@@ -229,9 +229,7 @@ public class ListBox extends TestCase
}
// create the table taking all those foreign keys
m_database.createTable( new HsqlTableDescriptor(
m_foreignKeyTableName,
foreignKeyColumns.toArray( new HsqlColumnDescriptor[foreignKeyColumns.size()] ) ) );
m_database.createTable( new HsqlTableDescriptor( m_foreignKeyTableName, foreignKeyColumns.toArray( new HsqlColumnDescriptor[foreignKeyColumns.size()] ) ) );
// fill in some data
foreignKeyInsertSQL.append( ")" );
XPreparedStatement statement = connection.prepareStatement( foreignKeyInsertSQL.toString() );
......
......@@ -304,7 +304,7 @@ public class CheckModuleAPI extends ComplexTestCase
moduleNames.add(sModuleName);
}
}
names = moduleNames.toArray(new String[0]);
names = moduleNames.toArray(new String[moduleNames.size()]);
}
catch (ParameterNotFoundException ex)
{
......@@ -465,7 +465,7 @@ public class CheckModuleAPI extends ComplexTestCase
}
}
final String[] names = moduleNames.toArray(new String[0]);
final String[] names = moduleNames.toArray(new String[moduleNames.size()]);
return names;
}
......
......@@ -174,7 +174,7 @@ public class CommandLineTools {
private boolean verbose = false;
private String language = null;
private MethodFinder finder = null;
private ArrayList scripts = null;
private ArrayList<ScriptEntry> scripts = null;
private HashMap properties = new HashMap(3);
public GenerateCommand(String basedir) {
......@@ -288,9 +288,7 @@ public class CommandLineTools {
throw new Exception("No valid scripts found");
ParcelDescriptor desc = new ParcelDescriptor(parcelxml, language);
desc.setScriptEntries((ScriptEntry[])scripts.toArray(new
ScriptEntry[scripts.size()]));
desc.setScriptEntries(scripts.toArray(new ScriptEntry[scripts.size()]));
if (properties.size() != 0) {
Enumeration enumer = properties.keys();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment