r/badcode • • Oct 06 '21

sql So umm this is from Twitch source code leak . NSFW

Post image
2.9k Upvotes

400 comments sorted by

View all comments

Show parent comments

2

u/[deleted] Oct 07 '21

You could just put the banned names in a hashset and look them up in O(1)

1

u/IAmTheSysGen Oct 07 '21

The idea is that you're searching for them in the username string.

1

u/Lost4468 Oct 07 '21

How would you go about doing that? These have to be able to appear anywhere in the username.

Would you get a hash for every possible series of characters in the username, and see if any of those hashes appear? That's only really going to be efficient if the number of banned names is very large.

Also of course it woudn't be as flexible.