Template which user provides and check if they are allowed to use or not
Whitelist domains are stored in the database
I wrote a regex which gets the domain names
I can iterate over the found domains and execute a select query for each domain to check if it's allowed or not
Now the bad thing is, domains in found domains could be duplicated, for example if there are 2 or more google.com in the template, it will execute select query for all of them
I can run another loop to remove duplicated domains from the list
But I'm not sure which one is more performance friendly
Having 2 loops next to each other or executing query for all of the domains even if they are duplicated
Which one do you think is better and why?
You didn't specify any language but in Python you can use a set instead of a list. It will remove any duplicate. And as a bonus because set items are hashed iterating over them is faster
Обсуждают сегодня