Game Development Stack Exchange is a question and answer site for professional and independent game developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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.

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

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.