r/badcode • • Jul 11 '21

python Boy, this is some real code for generating recursion errors

Post image
1.2k Upvotes

45 comments sorted by

View all comments

Show parent comments

1

u/[deleted] Jul 13 '21

From what I read from the article I skimmed they double looped it, so the inner loop is unnecessarily doing the same task 63k times with every iteration.

All they needed to do, as far as I got into the article, was read and hash 63k items once with multi threading instead of in one thread, if they needed to also download missing items from the item store, they can do that in a queue with 5-10 connections, so as you are going, you are looking for the items, reading items, hashing something, downloading something else, so you are utilizing the cpu, io, network, but also, and most importantly, not double looping if that’s a term or doing unnecessary steps, but I know gta 5 likes it’s micro transactions so their managers were problems like

Manager: Loading seems to take time Dev: it’s to make sure the store includes all the cosmetics and cars Manager: double and triple check it if need be, we are gonna get that money

1

u/sebamestre Jul 13 '21

From what i remember, that was not the case.

The inner loop was just the hash table collision resolution loop.

The thing is, the table had a single bucket, so every single element collided, and insertions became slow.

Just a simple mistake of not setting the table size correctly.