Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

I'd be afraid of the efficiency. Is there a better way?

share|improve this question

closed as not a real question by Maik Semder, Byte56, John McDonald, msell, Anko May 24 '13 at 13:05

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.If this question can be reworded to fit the rules in the help center, please edit the question.

5  
What do you mean by "resource locator"? When and in which context and how often do you want to use it? Why do you prefer a string over an enum? Which language and platform? There are a lot of question marks left open, that make it nearly impossible to give you a reasonable answer. Voting to close as this is not a real question in its current state. –  Maik Semder May 22 '13 at 18:03

1 Answer 1

Yes, it's perfectly fine to use a string as a key to look up resources. The "efficiency" of the check (the string comparison) isn't that damning on its own, especially if you do it intelligently and employ reasonable caching behavior, and so on.

A string has several advantages as well, such as affording you more data-driven flexibility than an enumeration will (since adding or changing enumerations usually means rebuilding code).

If the string look-ups ever do become a problem, according to your profiler, you can consider changing them to something else at that point.

share|improve this answer

Not the answer you're looking for? Browse other questions tagged or ask your own question.