Dictionary usage pattern

Forums 💬 NodeCanvas ⚙️ Support Dictionary usage pattern

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #17252
    bcristian
    Participant

      Hello
      Found the following pattern of checking if a key exists in a dictionary and then checking the value:
      if (dict.ContainKey(key) && dict[key] == value)
      this does 2 lookups, and can be optimized to do just one:

      I’ve encountered it PlayAnimationSimple and PlayAnimationAdvanced.
      Yes, I know the performamce impact in this case is minor to irrelevant 🙂

      #17253
      Gavalakis
      Keymaster

        Hey,

        Even if there is no apparent performance impact, it’s still good to keep with good practices.
        I’ve just changed the code there, which hopefully isn’t similar anywhere else.
        (PlayAnimationAdvanced does not have any dictionary usage by the way)

        Thank you.

      Viewing 2 posts - 1 through 2 (of 2 total)
      • You must be logged in to reply to this topic.