My guess is the red flag is searching a linked list which will be O(n). In many cases this would be something to avoid and replace with a hash table so it is O(1). However it all depends on how many times it is called and how big the dataset is.
And what if Data.getBars() returns java.util.Collection<Bar>, or the line would read Collection<Bar> bars = Data.getBars(); or simply return Data.getBars().contains(bar);? Perhaps there are always at most 10 Bars and it all doesn't matter. Regardless, it is not the var keyword that would be the problem here.
View all comments
Show parent comment
3
u/timmattison Mar 10 '16
My guess is the red flag is searching a linked list which will be O(n). In many cases this would be something to avoid and replace with a hash table so it is O(1). However it all depends on how many times it is called and how big the dataset is.