TokenMap#build builds a map of replica-maps per keyspace.
The replica-map depends on the replication strategy and its options (e.g. RF per DC).
If there are multiple keyspaces using the same replication-strategy + options, heap and CPU can be saved by reusing a matching replica-map. Heap and CPU consumption does not really matter for small clusters, but might be a problem with huge clusters (lots of nodes using vnodes and lots of keyspaces).
I've attached a patch against branch 2.1 for that.
Attached a second version that also cuts down heap usage for the map returned by ReplicationStrategy.computeTokenToReplicaMap (divide by number of vnodes).
I applied your patch v2 manually here. Can you have a look? Thanks!
Turns out the optimization in ReplicationStrategy.computeTokenToReplicaMap is wrong. We reverted that part of the patch.