cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jbel...@apache.org
Subject git commit: pre-size ArrayLists patch by Dave Brosius; reviewed by jbellis for CASSANDRA-3949
Date Thu, 23 Feb 2012 18:58:39 GMT
Updated Branches:
  refs/heads/trunk 950632012 -> 38ee718ee


pre-size ArrayLists
patch by Dave Brosius; reviewed by jbellis for CASSANDRA-3949


Project: http://git-wip-us.apache.org/repos/asf/cassandra/repo
Commit: http://git-wip-us.apache.org/repos/asf/cassandra/commit/38ee718e
Tree: http://git-wip-us.apache.org/repos/asf/cassandra/tree/38ee718e
Diff: http://git-wip-us.apache.org/repos/asf/cassandra/diff/38ee718e

Branch: refs/heads/trunk
Commit: 38ee718ee6edc0116a3727d9186b64272daa1018
Parents: 9506320
Author: Jonathan Ellis <jbellis@apache.org>
Authored: Thu Feb 23 12:58:23 2012 -0600
Committer: Jonathan Ellis <jbellis@apache.org>
Committed: Thu Feb 23 12:58:23 2012 -0600

----------------------------------------------------------------------
 .../org/apache/cassandra/config/KSMetaData.java    |    4 +-
 .../org/apache/cassandra/cql/DeleteStatement.java  |    2 +-
 .../org/apache/cassandra/cql/QueryProcessor.java   |   18 +++++----
 .../cassandra/cql3/statements/BatchStatement.java  |    2 +-
 .../statements/CreateColumnFamilyStatement.java    |    2 +-
 .../cassandra/cql3/statements/DeleteStatement.java |    2 +-
 .../cassandra/cql3/statements/SelectStatement.java |   11 +++---
 .../org/apache/cassandra/db/ColumnFamilyStore.java |    8 ++--
 src/java/org/apache/cassandra/db/DefsTable.java    |    9 +++--
 src/java/org/apache/cassandra/db/RowMutation.java  |    2 +-
 .../cassandra/db/SliceByNamesReadCommand.java      |    2 +-
 src/java/org/apache/cassandra/db/SystemTable.java  |    2 +-
 src/java/org/apache/cassandra/db/Table.java        |    2 +-
 .../cassandra/db/compaction/CompactionManager.java |   14 ++++---
 .../db/compaction/ParallelCompactionIterable.java  |    4 +-
 .../compaction/SizeTieredCompactionStrategy.java   |    2 +-
 .../cassandra/db/index/SecondaryIndexManager.java  |    4 +-
 .../db/marshal/AbstractCompositeType.java          |    4 +-
 .../dht/AbstractByteOrderedPartitioner.java        |    2 +-
 .../cassandra/dht/OrderPreservingPartitioner.java  |    2 +-
 src/java/org/apache/cassandra/dht/Range.java       |    4 +-
 .../cassandra/gms/GossipDigestSynVerbHandler.java  |    2 +-
 .../cassandra/io/sstable/ReducingKeyIterator.java  |    2 +-
 .../cassandra/locator/SimpleSeedProvider.java      |    2 +-
 .../org/apache/cassandra/net/MessagingService.java |    2 +-
 .../org/apache/cassandra/service/CacheService.java |    2 +-
 .../apache/cassandra/service/MigrationManager.java |    2 +-
 .../org/apache/cassandra/service/StorageProxy.java |    4 +-
 .../apache/cassandra/service/StorageService.java   |   27 ++++++++------
 .../cassandra/streaming/StreamRequestMessage.java  |    2 +-
 .../apache/cassandra/thrift/CassandraServer.java   |    4 +-
 31 files changed, 80 insertions(+), 71 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/38ee718e/src/java/org/apache/cassandra/config/KSMetaData.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/config/KSMetaData.java b/src/java/org/apache/cassandra/config/KSMetaData.java
index 48cb589..d8ef05f 100644
--- a/src/java/org/apache/cassandra/config/KSMetaData.java
+++ b/src/java/org/apache/cassandra/config/KSMetaData.java
@@ -189,7 +189,7 @@ public final class KSMetaData
 
     public KsDef toThrift()
     {
-        List<CfDef> cfDefs = new ArrayList<CfDef>();
+        List<CfDef> cfDefs = new ArrayList<CfDef>(cfMetaData.size());
         for (CFMetaData cfm : cfMetaData().values())
             cfDefs.add(cfm.toThrift());
         KsDef ksdef = new KsDef(name, strategyClass.getName(), cfDefs);
@@ -235,7 +235,7 @@ public final class KSMetaData
 
     public List<RowMutation> dropFromSchema(long timestamp)
     {
-        List<RowMutation> mutations = new ArrayList<RowMutation>();
+        List<RowMutation> mutations = new ArrayList<RowMutation>(cfMetaData.size());
 
         RowMutation ksMutation = new RowMutation(Table.SYSTEM_TABLE, SystemTable.getSchemaKSKey(name));
         ksMutation.delete(new QueryPath(SystemTable.SCHEMA_KEYSPACES_CF), timestamp);

http://git-wip-us.apache.org/repos/asf/cassandra/blob/38ee718e/src/java/org/apache/cassandra/cql/DeleteStatement.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/cql/DeleteStatement.java b/src/java/org/apache/cassandra/cql/DeleteStatement.java
index f19cd3b..cc026bd 100644
--- a/src/java/org/apache/cassandra/cql/DeleteStatement.java
+++ b/src/java/org/apache/cassandra/cql/DeleteStatement.java
@@ -74,7 +74,7 @@ public class DeleteStatement extends AbstractModification
         clientState.hasColumnFamilyAccess(columnFamily, Permission.WRITE);
         AbstractType<?> keyType = Schema.instance.getCFMetaData(keyspace, columnFamily).getKeyValidator();
 
-        List<IMutation> rowMutations = new ArrayList<IMutation>();
+        List<IMutation> rowMutations = new ArrayList<IMutation>(keys.size());
 
         for (Term key : keys)
         {

http://git-wip-us.apache.org/repos/asf/cassandra/blob/38ee718e/src/java/org/apache/cassandra/cql/QueryProcessor.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/cql/QueryProcessor.java b/src/java/org/apache/cassandra/cql/QueryProcessor.java
index befcb21..1a95d34 100644
--- a/src/java/org/apache/cassandra/cql/QueryProcessor.java
+++ b/src/java/org/apache/cassandra/cql/QueryProcessor.java
@@ -135,8 +135,9 @@ public class QueryProcessor
     throws InvalidRequestException
     {
         String keyString = getKeyString(metadata);
-        List<ByteBuffer> columnNames = new ArrayList<ByteBuffer>();
-        for (Term column : select.getColumnNames())
+        List<Term> selectColumnNames = select.getColumnNames();
+        List<ByteBuffer> columnNames = new ArrayList<ByteBuffer>(selectColumnNames.size());
+        for (Term column : selectColumnNames)
         {
             // skip the key for the slice op; we'll add it to the resultset in extractThriftColumns
             if (!column.getText().equalsIgnoreCase(keyString))
@@ -175,8 +176,9 @@ public class QueryProcessor
         SlicePredicate thriftSlicePredicate = slicePredicateFromSelect(select, metadata, variables);
         validateSlicePredicate(metadata, thriftSlicePredicate);
 
-        List<IndexExpression> expressions = new ArrayList<IndexExpression>();
-        for (Relation columnRelation : select.getColumnRelations())
+        List<Relation> columnRelations = select.getColumnRelations();
+        List<IndexExpression> expressions = new ArrayList<IndexExpression>(columnRelations.size());
+        for (Relation columnRelation : columnRelations)
         {
             // Left and right side of relational expression encoded according to comparator/validator.
             ByteBuffer entity = columnRelation.getEntity().getByteBuffer(metadata.comparator, variables);
@@ -237,8 +239,8 @@ public class QueryProcessor
     throws InvalidRequestException, UnavailableException, TimedOutException
     {
         String globalKeyspace = clientState.getKeyspace();
-        List<IMutation> rowMutations = new ArrayList<IMutation>();
-        List<String> cfamsSeen = new ArrayList<String>();
+        List<IMutation> rowMutations = new ArrayList<IMutation>(updateStatements.size());
+        List<String> cfamsSeen = new ArrayList<String>(updateStatements.size());
 
         for (UpdateStatement update : updateStatements)
         {
@@ -537,7 +539,7 @@ public class QueryProcessor
                                                 new HashMap<ByteBuffer, String>(),
                                                 TypeParser.getShortName(metadata.comparator),
                                                 TypeParser.getShortName(metadata.getDefaultValidator()));
-                List<CqlRow> cqlRows = new ArrayList<CqlRow>();
+                List<CqlRow> cqlRows = new ArrayList<CqlRow>(rows.size());
                 for (org.apache.cassandra.db.Row row : rows)
                 {
                     List<Column> thriftColumns = new ArrayList<Column>();
@@ -894,7 +896,7 @@ public class QueryProcessor
     throws RecognitionException, UnavailableException, InvalidRequestException, TimedOutException, SchemaDisagreementException
     {
         logger.trace("CQL QUERY: {}", queryString);
-        return processStatement(getStatement(queryString), clientState, new ArrayList<ByteBuffer>());
+        return processStatement(getStatement(queryString), clientState, new ArrayList<ByteBuffer>(0));
     }
 
     public static CqlPreparedResult prepare(String queryString, ClientState clientState)

http://git-wip-us.apache.org/repos/asf/cassandra/blob/38ee718e/src/java/org/apache/cassandra/cql3/statements/BatchStatement.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/cql3/statements/BatchStatement.java b/src/java/org/apache/cassandra/cql3/statements/BatchStatement.java
index 208d629..8fc5f07 100644
--- a/src/java/org/apache/cassandra/cql3/statements/BatchStatement.java
+++ b/src/java/org/apache/cassandra/cql3/statements/BatchStatement.java
@@ -149,7 +149,7 @@ public class BatchStatement extends ModificationStatement
 
     public ParsedStatement.Prepared prepare() throws InvalidRequestException
     {
-        List<AbstractType<?>> boundTypes = new ArrayList<AbstractType<?>>();
+        List<AbstractType<?>> boundTypes = new ArrayList<AbstractType<?>>(statements.size());
         // XXX: we use our knowledge that Modification don't create new
         // statement upon call to prepare()
         for (ModificationStatement statement : statements)

http://git-wip-us.apache.org/repos/asf/cassandra/blob/38ee718e/src/java/org/apache/cassandra/cql3/statements/CreateColumnFamilyStatement.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/cql3/statements/CreateColumnFamilyStatement.java b/src/java/org/apache/cassandra/cql3/statements/CreateColumnFamilyStatement.java
index 873c134..ecaed71 100644
--- a/src/java/org/apache/cassandra/cql3/statements/CreateColumnFamilyStatement.java
+++ b/src/java/org/apache/cassandra/cql3/statements/CreateColumnFamilyStatement.java
@@ -189,7 +189,7 @@ public class CreateColumnFamilyStatement extends SchemaAlteringStatement
                     }
                     else
                     {
-                        List<AbstractType<?>> types = new ArrayList<AbstractType<?>>();
+                        List<AbstractType<?>> types = new ArrayList<AbstractType<?>>(columnAliases.size() + 1);
                         for (ColumnIdentifier t : columnAliases)
                         {
                             stmt.columnAliases.add(t.key);

http://git-wip-us.apache.org/repos/asf/cassandra/blob/38ee718e/src/java/org/apache/cassandra/cql3/statements/DeleteStatement.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/cql3/statements/DeleteStatement.java b/src/java/org/apache/cassandra/cql3/statements/DeleteStatement.java
index 702ca5b..1987992 100644
--- a/src/java/org/apache/cassandra/cql3/statements/DeleteStatement.java
+++ b/src/java/org/apache/cassandra/cql3/statements/DeleteStatement.java
@@ -87,7 +87,7 @@ public class DeleteStatement extends ModificationStatement
             }
         }
 
-        List<IMutation> rowMutations = new ArrayList<IMutation>();
+        List<IMutation> rowMutations = new ArrayList<IMutation>(keys.size());
 
         for (Term key : keys)
         {

http://git-wip-us.apache.org/repos/asf/cassandra/blob/38ee718e/src/java/org/apache/cassandra/cql3/statements/SelectStatement.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/cql3/statements/SelectStatement.java b/src/java/org/apache/cassandra/cql3/statements/SelectStatement.java
index e8b7c45..4547cb8 100644
--- a/src/java/org/apache/cassandra/cql3/statements/SelectStatement.java
+++ b/src/java/org/apache/cassandra/cql3/statements/SelectStatement.java
@@ -418,9 +418,10 @@ public class SelectStatement implements CQLStatement
         }
         else
         {
-            List<ByteBuffer> columns = new ArrayList<ByteBuffer>();
             // Adds all (requested) columns
-            Iterator<Pair<CFDefinition.Name, ColumnIdentifier>> iter = getExpandedSelection().iterator();
+            List<Pair<CFDefinition.Name, ColumnIdentifier>> selection = getExpandedSelection();
+            List<ByteBuffer> columns = new ArrayList<ByteBuffer>(selection.size());
+            Iterator<Pair<CFDefinition.Name, ColumnIdentifier>> iter = selection.iterator();
             while (iter.hasNext())
             {
                 CFDefinition.Name name = iter.next().left;
@@ -589,7 +590,7 @@ public class SelectStatement implements CQLStatement
                     if (c.isMarkedForDelete())
                         continue;
 
-                    thriftColumns = new ArrayList<Column>();
+                    thriftColumns = new ArrayList<Column>(selection.size());
 
                     ByteBuffer[] components = cfDef.isComposite
                                             ? ((CompositeType)cfDef.cfm.comparator).split(c.name())
@@ -669,7 +670,7 @@ public class SelectStatement implements CQLStatement
             else
             {
                 // Static case: One cqlRow for all columns
-                thriftColumns = new ArrayList<Column>();
+                thriftColumns = new ArrayList<Column>(selection.size());
                 // Respect selection order
                 for (Pair<CFDefinition.Name, ColumnIdentifier> p : selection)
                 {
@@ -730,7 +731,7 @@ public class SelectStatement implements CQLStatement
 
     private CqlRow handleGroup(List<Pair<CFDefinition.Name, ColumnIdentifier>> selection, ByteBuffer key, ByteBuffer[] components, Map<ByteBuffer, IColumn> columns, CqlMetadata schema)
     {
-        List<Column> thriftColumns = new ArrayList<Column>();
+        List<Column> thriftColumns = new ArrayList<Column>(selection.size());
 
         // Respect requested order
         for (Pair<CFDefinition.Name, ColumnIdentifier> p : selection)

http://git-wip-us.apache.org/repos/asf/cassandra/blob/38ee718e/src/java/org/apache/cassandra/db/ColumnFamilyStore.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/db/ColumnFamilyStore.java b/src/java/org/apache/cassandra/db/ColumnFamilyStore.java
index 5243597..b8682aa 100644
--- a/src/java/org/apache/cassandra/db/ColumnFamilyStore.java
+++ b/src/java/org/apache/cassandra/db/ColumnFamilyStore.java
@@ -30,7 +30,6 @@ import javax.management.*;
 
 import com.google.common.collect.*;
 
-import org.apache.cassandra.db.compaction.LeveledManifest;
 import org.apache.cassandra.io.compress.CompressionParameters;
 import org.apache.cassandra.service.CacheService;
 import org.slf4j.Logger;
@@ -47,7 +46,6 @@ import org.apache.cassandra.db.commitlog.ReplayPosition;
 import org.apache.cassandra.db.compaction.AbstractCompactionStrategy;
 import org.apache.cassandra.db.compaction.CompactionManager;
 import org.apache.cassandra.db.compaction.LeveledCompactionStrategy;
-import org.apache.cassandra.db.compaction.LeveledManifest;
 import org.apache.cassandra.db.filter.ExtendedFilter;
 import org.apache.cassandra.db.filter.IFilter;
 import org.apache.cassandra.db.filter.QueryFilter;
@@ -56,6 +54,7 @@ import org.apache.cassandra.db.index.SecondaryIndex;
 import org.apache.cassandra.db.index.SecondaryIndexManager;
 import org.apache.cassandra.db.marshal.AbstractType;
 import org.apache.cassandra.dht.*;
+import org.apache.cassandra.dht.Range;
 import org.apache.cassandra.io.sstable.*;
 import org.apache.cassandra.io.sstable.Descriptor;
 import org.apache.cassandra.io.util.FileUtils;
@@ -1435,8 +1434,9 @@ public class ColumnFamilyStore implements ColumnFamilyStoreMBean
 
     public List<SSTableReader> getSnapshotSSTableReader(String tag) throws IOException
     {
-        List<SSTableReader> readers = new ArrayList<SSTableReader>();
-        for (Map.Entry<Descriptor, Set<Component>> entries : directories.sstableLister().snapshots(tag).list().entrySet())
+        Map<Descriptor, Set<Component>> snapshots = directories.sstableLister().snapshots(tag).list();
+        List<SSTableReader> readers = new ArrayList<SSTableReader>(snapshots.size());
+        for (Map.Entry<Descriptor, Set<Component>> entries : snapshots.entrySet())
             readers.add(SSTableReader.open(entries.getKey(), entries.getValue(), metadata, partitioner));
         return readers;
     }

http://git-wip-us.apache.org/repos/asf/cassandra/blob/38ee718e/src/java/org/apache/cassandra/db/DefsTable.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/db/DefsTable.java b/src/java/org/apache/cassandra/db/DefsTable.java
index f656a33..ddca205 100644
--- a/src/java/org/apache/cassandra/db/DefsTable.java
+++ b/src/java/org/apache/cassandra/db/DefsTable.java
@@ -146,7 +146,7 @@ public class DefsTable
     {
         List<Row> serializedSchema = SystemTable.serializedSchema(SystemTable.SCHEMA_KEYSPACES_CF);
 
-        List<KSMetaData> keyspaces = new ArrayList<KSMetaData>();
+        List<KSMetaData> keyspaces = new ArrayList<KSMetaData>(serializedSchema.size());
 
         for (Row row : serializedSchema)
         {
@@ -191,9 +191,10 @@ public class DefsTable
             org.apache.avro.Schema schema = org.apache.avro.Schema.parse(ByteBufferUtil.string(value));
 
             // deserialize keyspaces using schema
-            keyspaces = new ArrayList<KSMetaData>();
+            Collection<IColumn> columns = cf.getSortedColumns();
+            keyspaces = new ArrayList<KSMetaData>(columns.size());
 
-            for (IColumn column : cf.getSortedColumns())
+            for (IColumn column : columns)
             {
                 if (column.name().equals(DEFINITION_SCHEMA_COLUMN_NAME))
                     continue;
@@ -278,7 +279,7 @@ public class DefsTable
 
         // instead of looping over all modified entries and skipping processed keys all the time
         // we would rather store "left to process" items and iterate over them removing already met keys
-        List<DecoratedKey> leftToProcess = new ArrayList<DecoratedKey>();
+        List<DecoratedKey> leftToProcess = new ArrayList<DecoratedKey>(modifiedEntries.size());
 
         for (Map.Entry<DecoratedKey, MapDifference.ValueDifference<ColumnFamily>> entry : modifiedEntries.entrySet())
         {

http://git-wip-us.apache.org/repos/asf/cassandra/blob/38ee718e/src/java/org/apache/cassandra/db/RowMutation.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/db/RowMutation.java b/src/java/org/apache/cassandra/db/RowMutation.java
index 773877b..1844436 100644
--- a/src/java/org/apache/cassandra/db/RowMutation.java
+++ b/src/java/org/apache/cassandra/db/RowMutation.java
@@ -314,7 +314,7 @@ public class RowMutation implements IMutation, MessageProducer
         buff.append(", modifications=[");
         if (shallow)
         {
-            List<String> cfnames = new ArrayList<String>();
+            List<String> cfnames = new ArrayList<String>(modifications_.size());
             for (Integer cfid : modifications_.keySet())
             {
                 CFMetaData cfm = Schema.instance.getCFMetaData(cfid);

http://git-wip-us.apache.org/repos/asf/cassandra/blob/38ee718e/src/java/org/apache/cassandra/db/SliceByNamesReadCommand.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/db/SliceByNamesReadCommand.java b/src/java/org/apache/cassandra/db/SliceByNamesReadCommand.java
index bf3d16d..fe3f7ab 100644
--- a/src/java/org/apache/cassandra/db/SliceByNamesReadCommand.java
+++ b/src/java/org/apache/cassandra/db/SliceByNamesReadCommand.java
@@ -98,7 +98,7 @@ class SliceByNamesReadCommandSerializer implements IVersionedSerializer<ReadComm
         QueryPath columnParent = QueryPath.deserialize(dis);
 
         int size = dis.readInt();
-        List<ByteBuffer> columns = new ArrayList<ByteBuffer>();
+        List<ByteBuffer> columns = new ArrayList<ByteBuffer>(size);
         for (int i = 0; i < size; ++i)
         {
             columns.add(ByteBufferUtil.readWithShortLength(dis));

http://git-wip-us.apache.org/repos/asf/cassandra/blob/38ee718e/src/java/org/apache/cassandra/db/SystemTable.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/db/SystemTable.java b/src/java/org/apache/cassandra/db/SystemTable.java
index f4c03a9..9677fcc 100644
--- a/src/java/org/apache/cassandra/db/SystemTable.java
+++ b/src/java/org/apache/cassandra/db/SystemTable.java
@@ -526,7 +526,7 @@ public class SystemTable
 
     public static List<Row> serializedSchema()
     {
-        List<Row> schema = new ArrayList<Row>();
+        List<Row> schema = new ArrayList<Row>(3);
 
         schema.addAll(serializedSchema(SCHEMA_KEYSPACES_CF));
         schema.addAll(serializedSchema(SCHEMA_COLUMNFAMILIES_CF));

http://git-wip-us.apache.org/repos/asf/cassandra/blob/38ee718e/src/java/org/apache/cassandra/db/Table.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/db/Table.java b/src/java/org/apache/cassandra/db/Table.java
index 22285be..1a3de14 100644
--- a/src/java/org/apache/cassandra/db/Table.java
+++ b/src/java/org/apache/cassandra/db/Table.java
@@ -259,7 +259,7 @@ public class Table
      */
     public List<SSTableReader> getAllSSTables()
     {
-        List<SSTableReader> list = new ArrayList<SSTableReader>();
+        List<SSTableReader> list = new ArrayList<SSTableReader>(columnFamilyStores.size());
         for (ColumnFamilyStore cfStore : columnFamilyStores.values())
             list.addAll(cfStore.getSSTables());
         return list;

http://git-wip-us.apache.org/repos/asf/cassandra/blob/38ee718e/src/java/org/apache/cassandra/db/compaction/CompactionManager.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/db/compaction/CompactionManager.java b/src/java/org/apache/cassandra/db/compaction/CompactionManager.java
index ed699f2..bb221ce 100644
--- a/src/java/org/apache/cassandra/db/compaction/CompactionManager.java
+++ b/src/java/org/apache/cassandra/db/compaction/CompactionManager.java
@@ -325,7 +325,7 @@ public class CompactionManager implements CompactionManagerMBean
                 {
                     // look up the sstables now that we're on the compaction executor, so we don't try to re-compact
                     // something that was already being compacted earlier.
-                    Collection<SSTableReader> sstables = new ArrayList<SSTableReader>();
+                    Collection<SSTableReader> sstables = new ArrayList<SSTableReader>(dataFiles.size());
                     for (Descriptor desc : dataFiles)
                     {
                         // inefficient but not in a performance sensitive path
@@ -762,7 +762,7 @@ public class CompactionManager implements CompactionManagerMBean
                 executor.finishCompaction(ci);
             }
 
-            List<SSTableReader> results = new ArrayList<SSTableReader>();
+            List<SSTableReader> results = new ArrayList<SSTableReader>(1);
             if (newSstable != null)
             {
                 results.add(newSstable);
@@ -1065,16 +1065,18 @@ public class CompactionManager implements CompactionManagerMBean
 
     public List<Map<String, String>> getCompactions()
     {
-        List<Map<String, String>> out = new ArrayList<Map<String, String>>();
-        for (CompactionInfo.Holder ci : CompactionExecutor.getCompactions())
+        List<Holder> compactionHolders = CompactionExecutor.getCompactions();
+        List<Map<String, String>> out = new ArrayList<Map<String, String>>(compactionHolders.size());
+        for (CompactionInfo.Holder ci : compactionHolders)
             out.add(ci.getCompactionInfo().asMap());
         return out;
     }
 
     public List<String> getCompactionSummary()
     {
-        List<String> out = new ArrayList<String>();
-        for (CompactionInfo.Holder ci : CompactionExecutor.getCompactions())
+        List<Holder> compactionHolders = CompactionExecutor.getCompactions();
+        List<String> out = new ArrayList<String>(compactionHolders.size());
+        for (CompactionInfo.Holder ci : compactionHolders)
             out.add(ci.getCompactionInfo().toString());
         return out;
     }

http://git-wip-us.apache.org/repos/asf/cassandra/blob/38ee718e/src/java/org/apache/cassandra/db/compaction/ParallelCompactionIterable.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/db/compaction/ParallelCompactionIterable.java b/src/java/org/apache/cassandra/db/compaction/ParallelCompactionIterable.java
index dba8f55..194af2a 100644
--- a/src/java/org/apache/cassandra/db/compaction/ParallelCompactionIterable.java
+++ b/src/java/org/apache/cassandra/db/compaction/ParallelCompactionIterable.java
@@ -81,7 +81,7 @@ public class ParallelCompactionIterable extends AbstractCompactionIterable
 
     public CloseableIterator<AbstractCompactedRow> iterator()
     {
-        List<CloseableIterator<RowContainer>> sources = new ArrayList<CloseableIterator<RowContainer>>();
+        List<CloseableIterator<RowContainer>> sources = new ArrayList<CloseableIterator<RowContainer>>(scanners.size());
         for (SSTableScanner scanner : scanners)
             sources.add(new Deserializer(scanner, maxInMemorySize));
         return new Unwrapper(MergeIterator.get(sources, RowContainer.comparator, new Reducer()), controller);
@@ -189,7 +189,7 @@ public class ParallelCompactionIterable extends AbstractCompactionIterable
             if (inMemory)
                 return new CompactedRowContainer(rows.get(0).getKey(), executor.submit(new MergeTask(new ArrayList<RowContainer>(rows))));
 
-            List<ICountableColumnIterator> iterators = new ArrayList<ICountableColumnIterator>();
+            List<ICountableColumnIterator> iterators = new ArrayList<ICountableColumnIterator>(rows.size());
             for (RowContainer container : rows)
                 iterators.add(container.row == null ? container.wrapper : new DeserializedColumnIterator(container.row));
             return new CompactedRowContainer(new LazilyCompactedRow(controller, iterators));

http://git-wip-us.apache.org/repos/asf/cassandra/blob/38ee718e/src/java/org/apache/cassandra/db/compaction/SizeTieredCompactionStrategy.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/db/compaction/SizeTieredCompactionStrategy.java b/src/java/org/apache/cassandra/db/compaction/SizeTieredCompactionStrategy.java
index 9f11f19..0d963e0 100644
--- a/src/java/org/apache/cassandra/db/compaction/SizeTieredCompactionStrategy.java
+++ b/src/java/org/apache/cassandra/db/compaction/SizeTieredCompactionStrategy.java
@@ -119,7 +119,7 @@ public class SizeTieredCompactionStrategy extends AbstractCompactionStrategy
 
     private static List<Pair<SSTableReader, Long>> createSSTableAndLengthPairs(Collection<SSTableReader> collection)
     {
-        List<Pair<SSTableReader, Long>> tableLengthPairs = new ArrayList<Pair<SSTableReader, Long>>();
+        List<Pair<SSTableReader, Long>> tableLengthPairs = new ArrayList<Pair<SSTableReader, Long>>(collection.size());
         for(SSTableReader table: collection)
             tableLengthPairs.add(new Pair<SSTableReader, Long>(table, table.onDiskLength()));
         return tableLengthPairs;

http://git-wip-us.apache.org/repos/asf/cassandra/blob/38ee718e/src/java/org/apache/cassandra/db/index/SecondaryIndexManager.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/db/index/SecondaryIndexManager.java b/src/java/org/apache/cassandra/db/index/SecondaryIndexManager.java
index aa16db2..5fcb67d 100644
--- a/src/java/org/apache/cassandra/db/index/SecondaryIndexManager.java
+++ b/src/java/org/apache/cassandra/db/index/SecondaryIndexManager.java
@@ -538,8 +538,6 @@ public class SecondaryIndexManager
      */
     private List<SecondaryIndexSearcher> getIndexSearchersForQuery(List<IndexExpression> clause)
     {
-        List<SecondaryIndexSearcher> indexSearchers = new ArrayList<SecondaryIndexSearcher>();
-        
         Map<String, Set<ByteBuffer>> groupByIndexType = new HashMap<String, Set<ByteBuffer>>();
  
         
@@ -562,6 +560,8 @@ public class SecondaryIndexManager
             columns.add(ix.column_name);        
         }
         
+        List<SecondaryIndexSearcher> indexSearchers = new ArrayList<SecondaryIndexSearcher>(groupByIndexType.size());
+
         //create searcher per type
         for (Map.Entry<String, Set<ByteBuffer>> entry : groupByIndexType.entrySet())
         {

http://git-wip-us.apache.org/repos/asf/cassandra/blob/38ee718e/src/java/org/apache/cassandra/db/marshal/AbstractCompositeType.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/db/marshal/AbstractCompositeType.java b/src/java/org/apache/cassandra/db/marshal/AbstractCompositeType.java
index cfc3b2e..4a18ab8 100644
--- a/src/java/org/apache/cassandra/db/marshal/AbstractCompositeType.java
+++ b/src/java/org/apache/cassandra/db/marshal/AbstractCompositeType.java
@@ -161,8 +161,8 @@ public abstract class AbstractCompositeType extends AbstractType<ByteBuffer>
     public ByteBuffer fromString(String source)
     {
         String[] parts = source.split(":");
-        List<ByteBuffer> components = new ArrayList<ByteBuffer>();
-        List<ParsedComparator> comparators = new ArrayList<ParsedComparator>();
+        List<ByteBuffer> components = new ArrayList<ByteBuffer>(parts.length);
+        List<ParsedComparator> comparators = new ArrayList<ParsedComparator>(parts.length);
         int totalLength = 0, i = 0;
         boolean lastByteIsOne = false;
 

http://git-wip-us.apache.org/repos/asf/cassandra/blob/38ee718e/src/java/org/apache/cassandra/dht/AbstractByteOrderedPartitioner.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/dht/AbstractByteOrderedPartitioner.java b/src/java/org/apache/cassandra/dht/AbstractByteOrderedPartitioner.java
index 23c0123..89c5ac3 100644
--- a/src/java/org/apache/cassandra/dht/AbstractByteOrderedPartitioner.java
+++ b/src/java/org/apache/cassandra/dht/AbstractByteOrderedPartitioner.java
@@ -184,7 +184,7 @@ public abstract class AbstractByteOrderedPartitioner extends AbstractPartitioner
     {
         // allTokens will contain the count and be returned, sorted_ranges is shorthand for token<->token math.
         Map<Token, Float> allTokens = new HashMap<Token, Float>();
-        List<Range<Token>> sortedRanges = new ArrayList<Range<Token>>();
+        List<Range<Token>> sortedRanges = new ArrayList<Range<Token>>(sortedTokens.size());
 
         // this initializes the counts to 0 and calcs the ranges in order.
         Token lastToken = sortedTokens.get(sortedTokens.size() - 1);

http://git-wip-us.apache.org/repos/asf/cassandra/blob/38ee718e/src/java/org/apache/cassandra/dht/OrderPreservingPartitioner.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/dht/OrderPreservingPartitioner.java b/src/java/org/apache/cassandra/dht/OrderPreservingPartitioner.java
index 6c781f0..6ad536c 100644
--- a/src/java/org/apache/cassandra/dht/OrderPreservingPartitioner.java
+++ b/src/java/org/apache/cassandra/dht/OrderPreservingPartitioner.java
@@ -176,7 +176,7 @@ public class OrderPreservingPartitioner extends AbstractPartitioner<StringToken>
     {
         // allTokens will contain the count and be returned, sorted_ranges is shorthand for token<->token math.
         Map<Token, Float> allTokens = new HashMap<Token, Float>();
-        List<Range<Token>> sortedRanges = new ArrayList<Range<Token>>();
+        List<Range<Token>> sortedRanges = new ArrayList<Range<Token>>(sortedTokens.size());
 
         // this initializes the counts to 0 and calcs the ranges in order.
         Token lastToken = sortedTokens.get(sortedTokens.size() - 1);

http://git-wip-us.apache.org/repos/asf/cassandra/blob/38ee718e/src/java/org/apache/cassandra/dht/Range.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/dht/Range.java b/src/java/org/apache/cassandra/dht/Range.java
index 4478214..b759940 100644
--- a/src/java/org/apache/cassandra/dht/Range.java
+++ b/src/java/org/apache/cassandra/dht/Range.java
@@ -255,7 +255,7 @@ public class Range<T extends RingPosition> extends AbstractBounds<T> implements
      */
     private ArrayList<Range<T>> subtractContained(Range<T> contained)
     {
-        ArrayList<Range<T>> difference = new ArrayList<Range<T>>();
+        ArrayList<Range<T>> difference = new ArrayList<Range<T>>(2);
 
         if (!left.equals(contained.left))
             difference.add(new Range<T>(left, contained.left, partitioner));
@@ -359,7 +359,7 @@ public class Range<T extends RingPosition> extends AbstractBounds<T> implements
     public static <T extends RingPosition> List<Range<T>> normalize(Collection<Range<T>> ranges)
     {
         // unwrap all
-        List<Range<T>> output = new ArrayList<Range<T>>();
+        List<Range<T>> output = new ArrayList<Range<T>>(ranges.size());
         for (Range<T> range : ranges)
             output.addAll(range.unwrap());
 

http://git-wip-us.apache.org/repos/asf/cassandra/blob/38ee718e/src/java/org/apache/cassandra/gms/GossipDigestSynVerbHandler.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/gms/GossipDigestSynVerbHandler.java b/src/java/org/apache/cassandra/gms/GossipDigestSynVerbHandler.java
index 026f3fe..8e2e858 100644
--- a/src/java/org/apache/cassandra/gms/GossipDigestSynVerbHandler.java
+++ b/src/java/org/apache/cassandra/gms/GossipDigestSynVerbHandler.java
@@ -116,7 +116,7 @@ public class GossipDigestSynVerbHandler implements IVerbHandler
          * These digests have their maxVersion set to the difference of the version
          * of the local EndpointState and the version found in the GossipDigest.
         */
-        List<GossipDigest> diffDigests = new ArrayList<GossipDigest>();
+        List<GossipDigest> diffDigests = new ArrayList<GossipDigest>(gDigestList.size());
         for ( GossipDigest gDigest : gDigestList )
         {
             InetAddress ep = gDigest.getEndpoint();

http://git-wip-us.apache.org/repos/asf/cassandra/blob/38ee718e/src/java/org/apache/cassandra/io/sstable/ReducingKeyIterator.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/io/sstable/ReducingKeyIterator.java b/src/java/org/apache/cassandra/io/sstable/ReducingKeyIterator.java
index aa2618d..1a7da09 100644
--- a/src/java/org/apache/cassandra/io/sstable/ReducingKeyIterator.java
+++ b/src/java/org/apache/cassandra/io/sstable/ReducingKeyIterator.java
@@ -39,7 +39,7 @@ public class ReducingKeyIterator implements CloseableIterator<DecoratedKey>
 
     public ReducingKeyIterator(Collection<SSTableReader> sstables)
     {
-        ArrayList<KeyIterator> iters = new ArrayList<KeyIterator>();
+        ArrayList<KeyIterator> iters = new ArrayList<KeyIterator>(sstables.size());
         for (SSTableReader sstable : sstables)
             iters.add(new KeyIterator(sstable.descriptor));
         mi = MergeIterator.get(iters, DecoratedKey.comparator, new MergeIterator.Reducer<DecoratedKey,DecoratedKey>()

http://git-wip-us.apache.org/repos/asf/cassandra/blob/38ee718e/src/java/org/apache/cassandra/locator/SimpleSeedProvider.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/locator/SimpleSeedProvider.java b/src/java/org/apache/cassandra/locator/SimpleSeedProvider.java
index 7f20da1..52ebb91 100644
--- a/src/java/org/apache/cassandra/locator/SimpleSeedProvider.java
+++ b/src/java/org/apache/cassandra/locator/SimpleSeedProvider.java
@@ -37,8 +37,8 @@ public class SimpleSeedProvider implements SeedProvider
     
     public SimpleSeedProvider(Map<String, String> args)
     {
-        seeds = new ArrayList<InetAddress>();
         String[] hosts = args.get("seeds").split(",", -1);
+        seeds = new ArrayList<InetAddress>(hosts.length);
         for (String host : hosts)
         {
             try

http://git-wip-us.apache.org/repos/asf/cassandra/blob/38ee718e/src/java/org/apache/cassandra/net/MessagingService.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/net/MessagingService.java b/src/java/org/apache/cassandra/net/MessagingService.java
index 0bb36fb..a099629 100644
--- a/src/java/org/apache/cassandra/net/MessagingService.java
+++ b/src/java/org/apache/cassandra/net/MessagingService.java
@@ -257,7 +257,7 @@ public final class MessagingService implements MessagingServiceMBean
 
     private List<ServerSocket> getServerSocket(InetAddress localEp) throws IOException, ConfigurationException
     {
-       final List<ServerSocket> ss = new ArrayList<ServerSocket>();
+       final List<ServerSocket> ss = new ArrayList<ServerSocket>(2);
         if (DatabaseDescriptor.getEncryptionOptions().internode_encryption != EncryptionOptions.InternodeEncryption.none)
         {
             ss.add(SSLFactory.getServerSocket(DatabaseDescriptor.getEncryptionOptions(), localEp, DatabaseDescriptor.getSSLStoragePort()));

http://git-wip-us.apache.org/repos/asf/cassandra/blob/38ee718e/src/java/org/apache/cassandra/service/CacheService.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/service/CacheService.java b/src/java/org/apache/cassandra/service/CacheService.java
index 6438165..4913957 100644
--- a/src/java/org/apache/cassandra/service/CacheService.java
+++ b/src/java/org/apache/cassandra/service/CacheService.java
@@ -275,7 +275,7 @@ public class CacheService implements CacheServiceMBean
 
     public void saveCaches() throws ExecutionException, InterruptedException
     {
-        List<Future<?>> futures = new ArrayList<Future<?>>();
+        List<Future<?>> futures = new ArrayList<Future<?>>(2);
         logger.debug("submitting cache saves");
 
         futures.add(keyCache.submitWrite(DatabaseDescriptor.getKeyCacheKeysToSave()));

http://git-wip-us.apache.org/repos/asf/cassandra/blob/38ee718e/src/java/org/apache/cassandra/service/MigrationManager.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/service/MigrationManager.java b/src/java/org/apache/cassandra/service/MigrationManager.java
index 6990d84..06d8095 100644
--- a/src/java/org/apache/cassandra/service/MigrationManager.java
+++ b/src/java/org/apache/cassandra/service/MigrationManager.java
@@ -233,7 +233,7 @@ public class MigrationManager implements IEndpointStateChangeSubscriber
                 logger.debug("Truncating schema tables...");
 
             // truncate schema tables
-            FBUtilities.waitOnFutures(new ArrayList<Future<?>>()
+            FBUtilities.waitOnFutures(new ArrayList<Future<?>>(3)
             {{
                 SystemTable.schemaCFS(SystemTable.SCHEMA_KEYSPACES_CF).truncate();
                 SystemTable.schemaCFS(SystemTable.SCHEMA_COLUMNFAMILIES_CF).truncate();

http://git-wip-us.apache.org/repos/asf/cassandra/blob/38ee718e/src/java/org/apache/cassandra/service/StorageProxy.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/service/StorageProxy.java b/src/java/org/apache/cassandra/service/StorageProxy.java
index 72cdd1b..bb005ae 100644
--- a/src/java/org/apache/cassandra/service/StorageProxy.java
+++ b/src/java/org/apache/cassandra/service/StorageProxy.java
@@ -177,7 +177,7 @@ public class StorageProxy implements StorageProxyMBean
         final String localDataCenter = DatabaseDescriptor.getEndpointSnitch().getDatacenter(FBUtilities.getBroadcastAddress());
 
         long startTime = System.nanoTime();
-        List<IWriteResponseHandler> responseHandlers = new ArrayList<IWriteResponseHandler>();
+        List<IWriteResponseHandler> responseHandlers = new ArrayList<IWriteResponseHandler>(mutations.size());
 
         IMutation mostRecentMutation = null;
         try
@@ -206,7 +206,7 @@ public class StorageProxy implements StorageProxyMBean
         {
             if (logger.isDebugEnabled())
             {
-                List<String> mstrings = new ArrayList<String>();
+                List<String> mstrings = new ArrayList<String>(mutations.size());
                 for (IMutation mutation : mutations)
                     mstrings.add(mutation.toString(true));
                 logger.debug("Write timeout {} for one (or more) of: ", ex.toString(), mstrings);

http://git-wip-us.apache.org/repos/asf/cassandra/blob/38ee718e/src/java/org/apache/cassandra/service/StorageService.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/service/StorageService.java b/src/java/org/apache/cassandra/service/StorageService.java
index 580ec26..57e198d 100644
--- a/src/java/org/apache/cassandra/service/StorageService.java
+++ b/src/java/org/apache/cassandra/service/StorageService.java
@@ -48,6 +48,7 @@ import org.apache.cassandra.db.*;
 import org.apache.cassandra.db.Table;
 import org.apache.cassandra.db.commitlog.CommitLog;
 import org.apache.cassandra.dht.*;
+import org.apache.cassandra.dht.Range;
 import org.apache.cassandra.gms.*;
 import org.apache.cassandra.io.sstable.SSTableDeletingTask;
 import org.apache.cassandra.io.sstable.SSTableLoader;
@@ -805,7 +806,7 @@ public class StorageService implements IEndpointStateChangeSubscriber, StorageSe
         Map<List<String>, List<String>> map = new HashMap<List<String>, List<String>>();
         for (Map.Entry<Range<Token>, List<InetAddress>> entry : getRangeToAddressMap(keyspace).entrySet())
         {
-            List<String> rpcaddrs = new ArrayList<String>();
+            List<String> rpcaddrs = new ArrayList<String>(entry.getValue().size());
             for (InetAddress endpoint: entry.getValue())
             {
                 rpcaddrs.add(getRpcaddress(endpoint));
@@ -853,9 +854,10 @@ public class StorageService implements IEndpointStateChangeSubscriber, StorageSe
      */
     public List<String> describeRingJMX(String keyspace) throws InvalidRequestException
     {
-        List<String> result = new ArrayList<String>();
+        List<TokenRange> tokenRanges = describeRing(keyspace);
+        List<String> result = new ArrayList<String>(tokenRanges.size());
 
-        for (TokenRange tokenRange : describeRing(keyspace))
+        for (TokenRange tokenRange : tokenRanges)
             result.add(tokenRange.toString());
 
         return result;
@@ -881,11 +883,12 @@ public class StorageService implements IEndpointStateChangeSubscriber, StorageSe
         for (Map.Entry<Range<Token>, List<InetAddress>> entry : getRangeToAddressMap(keyspace).entrySet())
         {
             Range range = entry.getKey();
-            List<String> endpoints = new ArrayList<String>();
-            List<String> rpc_endpoints = new ArrayList<String>();
-            List<EndpointDetails> epDetails = new ArrayList<EndpointDetails>();
+            List<InetAddress> addresses = entry.getValue();
+            List<String> endpoints = new ArrayList<String>(addresses.size());
+            List<String> rpc_endpoints = new ArrayList<String>(addresses.size());
+            List<EndpointDetails> epDetails = new ArrayList<EndpointDetails>(addresses.size());
 
-            for (InetAddress endpoint : entry.getValue())
+            for (InetAddress endpoint : addresses)
             {
                 EndpointDetails details = new EndpointDetails();
                 details.host = endpoint.getHostAddress();
@@ -1748,7 +1751,7 @@ public class StorageService implements IEndpointStateChangeSubscriber, StorageSe
         }
         else
         {
-            ArrayList<Table> t = new ArrayList<Table>();
+            ArrayList<Table> t = new ArrayList<Table>(tableNames.length);
             for (String table : tableNames)
                 t.add(getValidTable(table));
             tables = t;
@@ -1789,7 +1792,7 @@ public class StorageService implements IEndpointStateChangeSubscriber, StorageSe
         }
         else
         {
-            ArrayList<Table> tempTables = new ArrayList<Table>();
+            ArrayList<Table> tempTables = new ArrayList<Table>(tableNames.length);
             for(String table : tableNames)
                 tempTables.add(getValidTable(table));
             tables = tempTables;
@@ -1982,8 +1985,8 @@ public class StorageService implements IEndpointStateChangeSubscriber, StorageSe
 
         if (sortedTokens.isEmpty())
             return Collections.emptyList();
-        List<Range<Token>> ranges = new ArrayList<Range<Token>>();
         int size = sortedTokens.size();
+        List<Range<Token>> ranges = new ArrayList<Range<Token>>(size + 1);
         for (int i = 1; i < size; ++i)
         {
             Range<Token> range = new Range<Token>(sortedTokens.get(i - 1), sortedTokens.get(i));
@@ -2043,8 +2046,8 @@ public class StorageService implements IEndpointStateChangeSubscriber, StorageSe
 
     public List<InetAddress> getLiveNaturalEndpoints(String table, RingPosition pos)
     {
-        List<InetAddress> liveEps = new ArrayList<InetAddress>();
         List<InetAddress> endpoints = Table.open(table).getReplicationStrategy().getNaturalEndpoints(pos);
+        List<InetAddress> liveEps = new ArrayList<InetAddress>(endpoints.size());
 
         for (InetAddress endpoint : endpoints)
         {
@@ -2962,7 +2965,7 @@ public class StorageService implements IEndpointStateChangeSubscriber, StorageSe
     {
         List<DecoratedKey> keys = keySamples(ColumnFamilyStore.allUserDefined(), getLocalPrimaryRange());
 
-        List<String> sampledKeys = new ArrayList<String>();
+        List<String> sampledKeys = new ArrayList<String>(keys.size());
         for (DecoratedKey key : keys)
             sampledKeys.add(key.getToken().toString());
         return sampledKeys;

http://git-wip-us.apache.org/repos/asf/cassandra/blob/38ee718e/src/java/org/apache/cassandra/streaming/StreamRequestMessage.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/streaming/StreamRequestMessage.java b/src/java/org/apache/cassandra/streaming/StreamRequestMessage.java
index c5179ba..fc913c1 100644
--- a/src/java/org/apache/cassandra/streaming/StreamRequestMessage.java
+++ b/src/java/org/apache/cassandra/streaming/StreamRequestMessage.java
@@ -182,7 +182,7 @@ class StreamRequestMessage implements MessageProducer
             {
                 String table = dis.readUTF();
                 int size = dis.readInt();
-                List<Range<Token>> ranges = (size == 0) ? null : new ArrayList<Range<Token>>();
+                List<Range<Token>> ranges = (size == 0) ? null : new ArrayList<Range<Token>>(size);
                 for( int i = 0; i < size; ++i )
                 {
                     ranges.add((Range<Token>) AbstractBounds.serializer().deserialize(dis, version).toTokenBounds());

http://git-wip-us.apache.org/repos/asf/cassandra/blob/38ee718e/src/java/org/apache/cassandra/thrift/CassandraServer.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/thrift/CassandraServer.java b/src/java/org/apache/cassandra/thrift/CassandraServer.java
index 2503315..adb053c 100644
--- a/src/java/org/apache/cassandra/thrift/CassandraServer.java
+++ b/src/java/org/apache/cassandra/thrift/CassandraServer.java
@@ -336,7 +336,7 @@ public class CassandraServer implements Cassandra.Iface
         ThriftValidation.validatePredicate(metadata, column_parent, predicate);
         ThriftValidation.validateConsistencyLevel(keyspace, consistency_level, RequestType.READ);
 
-        List<ReadCommand> commands = new ArrayList<ReadCommand>();
+        List<ReadCommand> commands = new ArrayList<ReadCommand>(keys.size());
         if (predicate.column_names != null)
         {
             for (ByteBuffer key: keys)
@@ -834,7 +834,7 @@ public class CassandraServer implements Cassandra.Iface
         state().hasKeyspaceSchemaAccess(Permission.READ);
 
         Set<String> keyspaces = Schema.instance.getTables();
-        List<KsDef> ksset = new ArrayList<KsDef>();
+        List<KsDef> ksset = new ArrayList<KsDef>(keyspaces.size());
         for (String ks : keyspaces)
         {
             try


Mime
View raw message