Skip to main content
May 4, 2009
Question

StructFindKey() vs. Evaluate()

  • May 4, 2009
  • 3 replies
  • 886 views

Does anyone know what the performance difference is between using structFindKey() and evaluate()? Thanks!

    This topic has been closed for replies.

    3 replies

    BKBK
    Community Expert
    Community Expert
    May 4, 2009

    You're comparing apples with pears. The functions structFindKey() and evaluate() don't even share the same arguments.

    Inspiring
    May 5, 2009

    semi star gazer  - do you mean StructFindValue()?  That might make a little more sense in this context - may you're using them both to accomplish the same thing - i.e. dynamically evaluating the contents of a structure.

    #Evaluate("stMyStruct." & item)#

    vs

    #StructFindValue(stMyStruct, item, "one")#

    If this is the case, your best bet is to use neither and switch to using the following structure notation in CF:

    #Struct["key"]#

    using the above syntax, you can accomplish the same Evaluate/FindValue task using the following code:

    #stMyStruct[item]#

    The above code dynamically evaluates the value of "item" as the key in structure stMyStruct and returns whatever value is stored in that key.

    Let us know if that was what you were looking for, if not can you clarify how you inteded on using both functions?

    Hope that helps,

    - Michael

    Inspiring
    May 4, 2009

    What difference does performance make?  The two functions do different things.

    Inspiring
    May 4, 2009

    I've always thought (and seem to recall reading this in various spots) that Evaluate was one of the slowest executing/worst performing functions.

    Here's a Fusion Authority page that references avoiding Evaluate():

    http://www.fusionauthority.com/news/4755-coldfusion-talk-roundup-7.htm