|
|
|
|
|
by dozzie
3252 days ago
|
|
Dude, you're leaving O(n^2) landmines in your code and you're now justifying
them by linecount and readability (actually more like familiarity with using
sets and mappings). You have just proved my intuition about your abilities. Not to menion that: > you suggest 'a. k. a. "dictionaries"' but that is slower In what way you think mappings are different in implementation than sets that
makes them slower? They only need to carry one more pointer, and you're
already writing in a language quite detached from bare metal. One more thing, since you decided to "correct" yourself instead of letting
the mistake slip: your "working" code is still wrong, unless something very
weird happens in the data (but then calling it more readable this way is
fundamentally wrong). |
|
O(n^2) I do not dispute. "Landmines," however, I take offense at: my naive implementation can still check 10,000 items in less than three seconds; should this ever become a bottleneck I assure you that I will adjust the implementation accordingly. Considering that hitting this number would require expanding the entire company at least tenfold, and knowing how other portions of the code work, I feel justified in saying that this is likely to be the least of their problems.
> you're now justifying them by linecount and readability (actually more like familiarity with using sets and mappings).
The entire point of this thread was justifying by readability, so yes, I am. I'm well familiar with sets and mappings, I just don't think that they're the best solution for this particular task.
> In what way you think mappings are different in implementation than sets that makes them slower?
I don't know the internal implementation details, but having just benchmarked it I can tell you that Dictionary<string, Item> is roughly 8% slower than HashSet<string> for two otherwise identical implementations of this method.
> You have just proved my intuition about your abilities.
Likewise. From the preceding conversation, I conclude that you are inclined to prematurely optimize at the cost of maintainability and that you tend to look down on and make fun of anyone who you believe knows less about a topic than you, without taking the time to consider their point of view, or even basic politeness. You may not think that this description accurately depicts you; but then I don't think your opinion of me seems to be correct either.
Considering that I have now spent far more time than this code will ever run for arguing the point, I'm going to step away from this discussion now. I feel that I have made my point; increasingly heated argument seems unlikely to affect the outcome of the debate.