[
https://issues.apache.org/jira/browse/CASSANDRA-275?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12728400#action_12728400
]
Edward Ribeiro commented on CASSANDRA-275:
------------------------------------------
Yes, I really forgot to use code conventions this time, but this can be fixed
with another patch. Sorry for that. I agree that the code with entrySet looks
a bit uglier, but it's just a matter of getting used to it.
Well, the patch can be thrown out, but there are some places where the code
cries for better coding, like the following (Gossiper class):
Map<String, ApplicationState> appStateMap =
epState.getApplicationState();
Set<String> keys = appStateMap.keySet();
for ( String key : keys )
{
int stateVersion = appStateMap.get(key).getStateVersion();
versions.add( stateVersion );
}
Well, if it's iterating over all the values of the map why not just do the
following?
Map<String, ApplicationState> appStateMap =
epState.getApplicationState();
for (ApplicationState appState : appStateMap.values())
{
int stateVersion = appState.getStateVersion();
versions.add( stateVersion );
}
As I said before, this patch can be thrown out, but these wtf code snippets as
the one above, that was fixed by this patch, should still be the target of
better coding for the benefit of the long term Cassandra maintenance.
> Replace Map.keySet by more efficient Map.entrySet
> -------------------------------------------------
>
> Key: CASSANDRA-275
> URL: https://issues.apache.org/jira/browse/CASSANDRA-275
> Project: Cassandra
> Issue Type: Improvement
> Reporter: Edward Ribeiro
> Priority: Minor
> Attachments: CASSANDRA-275.patch
>
>
> When you iterates over all key-values of a Map is better to use entrySet()
> instead of a call to entryKey() and a call to get() inside the loop. It's
> more efficient.
> I've seen a patch like this before, but I don't think it was applied at all.
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.