Jump to content

  • Log In with Google      Sign In   
  • Create Account

14 years ago on June 15th Gamedev.net was first launched! We want to thank all of you for being part of our community and hope the best years are ahead of us. Happy birthday Gamedev.net!

#ActualServant of the Lord

Posted 16 July 2012 - 11:22 AM

[Edit:] Double-posted for some reason. Can't seem to find the 'delete post' button.

#1Servant of the Lord

Posted 16 July 2012 - 11:14 AM

I seriously hope you're jocking.
Using this to not store the permutations is not saving space.
Rather, doing the permutation thing is brain damaged. And don't even get me started on checking the match. I'm sure I've seen it on the daily WTF.
Thus, not storing them is not about saving space but rather doing things right.

I'm confused about what you are disagreeing with.

Are you saying that this...
if(name == "person mcperson" || name == "Person Mcperson" || name == "Person McPerson"
|| name == "PERSON MCPERSON" || name == "person MCPERSON" || name == "PERSON mcperson" || ...etc... )
{
	 //...
}

...is better than this:
std::string name = "Person McPerson";
std::transform(name.begin(), name.end(), name.begin(), ::tolower);
if(name == "person mcperson")
{
	 //...
}

Or are you just saying to cache the lowercase name when possible, so you don't have to convert it every function call?

As for 'saving space', I fully agree that any 'space' you save is absurdly small and unimportant if developing for a modern PC. For me, the benefit of the second one is about writing cleaner and easier-to-maintain code, and also ensuring you catch all the valid possibilities and not just some of them.

PARTNERS