3 ms·
I have to wonder about an architecture where he's creating thousands of these hash objects and then rarely using them. Initializing them to size 0 was a workar
by jandrese 7y ago
I have to wonder about an architecture where he's creating thousands of these hash objects and then rarely using them. Initializing them to size 0 was a workaround, but it makes me wonder if maybe he should consider lazy evaluation where the objects are only created if they're actually used? That's still a bunch of CPU cycles burned churning through the setup/teardown of empty hash tables.
- draw_down 7y agoIronically, if this had been raised at the time I bet it would have been shot down as premature optimization!
- ambulancechaser 7y agoThe article mentions that they rarely had elements, not that they were rarely used. They might have been tested for membership in lots of hot paths. There's no way to know. And I bet a lazily-instantiated set might take up even more space than a regular set anyways. And if they are often used, even if not added to, it would have made the problem even worse.