<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	>
<channel>
	<title>Comments on: isDefined() vs structKeyExists()</title>
	<atom:link href="http://www.simonwhatley.co.uk/isdefined-vs-structkeyexists/feed" rel="self" type="application/rss+xml" />
	<link>http://www.simonwhatley.co.uk/isdefined-vs-structkeyexists</link>
	<description>The opposite of every great idea is another great idea</description>
	<pubDate>Fri, 21 Nov 2008 22:14:51 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.6.3</generator>
		<item>
		<title>By: Paul Thornton</title>
		<link>http://www.simonwhatley.co.uk/isdefined-vs-structkeyexists#comment-2945</link>
		<dc:creator>Paul Thornton</dc:creator>
		<pubDate>Mon, 24 Sep 2007 16:08:31 +0000</pubDate>
		<guid isPermaLink="false">http://www.simonwhatley.co.uk/?p=341#comment-2945</guid>
		<description>I dropped using isDefined() many moons ago as well, I thought it was common knowledge that isDefined() was inefficient and structKeyExists() was the way to go.  

Well, reading around and coming across &lt;a href="http://www.placona.co.uk/blog/index.cfm/2006/11/30/Performance-Test-isDefined-x-structKeyExists" rel="nofollow"&gt;Marcos Placona's blog&lt;/a&gt; where he has conducted a test, it turns out, to my amazement, structKeyExists() is slower then isDefined()!  

The key here is that isDefined() is super-fast when the scope exists, i.e. isDefined("session.userID"), but mega-slow if a non-existent scope is used, e.g. isDefined("unknownStruct.userID").

structKeyExists() is consistent regardless of what you provide.

So, as long as you are asking for a SCOPED variable that is extant, isDefined will be faster on average!

structKeyExists(), may be comparatively slower, but forces scoping, which is good practice.</description>
		<content:encoded><![CDATA[<p>I dropped using isDefined() many moons ago as well, I thought it was common knowledge that isDefined() was inefficient and structKeyExists() was the way to go.  </p>
<p>Well, reading around and coming across <a href="http://www.placona.co.uk/blog/index.cfm/2006/11/30/Performance-Test-isDefined-x-structKeyExists" rel="nofollow">Marcos Placona&#8217;s blog</a> where he has conducted a test, it turns out, to my amazement, structKeyExists() is slower then isDefined()!  </p>
<p>The key here is that isDefined() is super-fast when the scope exists, i.e. isDefined(&#8221;session.userID&#8221;), but mega-slow if a non-existent scope is used, e.g. isDefined(&#8221;unknownStruct.userID&#8221;).</p>
<p>structKeyExists() is consistent regardless of what you provide.</p>
<p>So, as long as you are asking for a SCOPED variable that is extant, isDefined will be faster on average!</p>
<p>structKeyExists(), may be comparatively slower, but forces scoping, which is good practice.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Russell Brown</title>
		<link>http://www.simonwhatley.co.uk/isdefined-vs-structkeyexists#comment-2944</link>
		<dc:creator>Russell Brown</dc:creator>
		<pubDate>Mon, 24 Sep 2007 11:58:15 +0000</pubDate>
		<guid isPermaLink="false">http://www.simonwhatley.co.uk/?p=341#comment-2944</guid>
		<description>I also believe there is another performance factor with isDefined. When you execute something like isDefined("session.user") is checks other scopes for the key as well  such as variables.session.user and request.session.user. I stopped using isDefined() all together years ago now and I'm not sure of a reason why to use it, unless maybe you don't know what scope the var will be in [variable, form, url].</description>
		<content:encoded><![CDATA[<p>I also believe there is another performance factor with isDefined. When you execute something like isDefined(&#8221;session.user&#8221;) is checks other scopes for the key as well  such as variables.session.user and request.session.user. I stopped using isDefined() all together years ago now and I&#8217;m not sure of a reason why to use it, unless maybe you don&#8217;t know what scope the var will be in [variable, form, url].</p>
]]></content:encoded>
	</item>
</channel>
</rss>
