Return-Path: X-Original-To: apmail-flex-dev-archive@www.apache.org Delivered-To: apmail-flex-dev-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id EFB3E10085 for ; Fri, 3 Jan 2014 01:26:42 +0000 (UTC) Received: (qmail 33984 invoked by uid 500); 3 Jan 2014 01:26:42 -0000 Delivered-To: apmail-flex-dev-archive@flex.apache.org Received: (qmail 33951 invoked by uid 500); 3 Jan 2014 01:26:42 -0000 Mailing-List: contact dev-help@flex.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@flex.apache.org Delivered-To: mailing list dev@flex.apache.org Received: (qmail 33943 invoked by uid 99); 3 Jan 2014 01:26:42 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 03 Jan 2014 01:26:42 +0000 X-ASF-Spam-Status: No, hits=-0.0 required=5.0 tests=RCVD_IN_DNSWL_NONE,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: local policy includes SPF record at spf.trusted-forwarder.org) Received: from [203.59.1.220] (HELO icp-osb-irony-out4.external.iinet.net.au) (203.59.1.220) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 03 Jan 2014 01:26:35 +0000 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AngDAHYQxlLLnjUD/2dsb2JhbAANS70NAoEjg1pnsUCaThePOoMNgRMEnwOOaQ X-IronPort-AV: E=Sophos;i="4.95,594,1384272000"; d="scan'208";a="172537614" Received: from unknown (HELO [192.168.0.4]) ([203.158.53.3]) by icp-osb-irony-out4.iinet.net.au with ESMTP; 03 Jan 2014 09:26:11 +0800 From: Justin Mclean Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: quoted-printable Subject: try/catch vs in Date: Fri, 3 Jan 2014 12:26:11 +1100 Message-Id: To: dev@flex.apache.org Mime-Version: 1.0 (Apple Message framework v1283) X-Mailer: Apple Mail (2.1283) X-Virus-Checked: Checked by ClamAV on apache.org Hi, While looking at some data grid code I noticed this: try { data =3D data[dataField]; } catch(e:Error) { data =3D null; } And I was curious to why try catch is used rather than this: if (dataField in data) { data =3D data[dataField]; } else { data =3D null; } I know "in" can be expensive but so is try catch. I've run each though = scout and it looks like the in operator is orders of magnitude faster = and caused no garbage collection both when the field exists and when it = doesn't. Anyone have any insight/something to add? Thanks, Justin=