Return-Path: X-Original-To: apmail-incubator-flex-dev-archive@minotaur.apache.org Delivered-To: apmail-incubator-flex-dev-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id B472F9B7D for ; Fri, 24 Feb 2012 11:10:07 +0000 (UTC) Received: (qmail 95990 invoked by uid 500); 24 Feb 2012 11:10:07 -0000 Delivered-To: apmail-incubator-flex-dev-archive@incubator.apache.org Received: (qmail 95960 invoked by uid 500); 24 Feb 2012 11:10:07 -0000 Mailing-List: contact flex-dev-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: flex-dev@incubator.apache.org Delivered-To: mailing list flex-dev@incubator.apache.org Received: (qmail 95952 invoked by uid 99); 24 Feb 2012 11:10:07 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 24 Feb 2012 11:10:07 +0000 X-ASF-Spam-Status: No, hits=1.5 required=5.0 tests=HTML_MESSAGE,RCVD_IN_DNSWL_LOW,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of olegsivokon@gmail.com designates 209.85.210.175 as permitted sender) Received: from [209.85.210.175] (HELO mail-iy0-f175.google.com) (209.85.210.175) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 24 Feb 2012 11:09:59 +0000 Received: by iaby12 with SMTP id y12so3094039iab.6 for ; Fri, 24 Feb 2012 03:09:37 -0800 (PST) Received-SPF: pass (google.com: domain of olegsivokon@gmail.com designates 10.43.44.69 as permitted sender) client-ip=10.43.44.69; Authentication-Results: mr.google.com; spf=pass (google.com: domain of olegsivokon@gmail.com designates 10.43.44.69 as permitted sender) smtp.mail=olegsivokon@gmail.com; dkim=pass header.i=olegsivokon@gmail.com Received: from mr.google.com ([10.43.44.69]) by 10.43.44.69 with SMTP id uf5mr1659064icb.41.1330081777786 (num_hops = 1); Fri, 24 Feb 2012 03:09:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; bh=cICVVPPY0jQzc90Cm0YBQeL0uutZ4J7vEigIM0sW1yo=; b=wJ7AT/3jy1BkSOSKXu8efSKomwP5VsEWAsEMhJuIXHJm/tS4CHlgfz7aAUsp8PQ0gW zJozzoCxz5fHBL6hzeYNIRUITpxLYmyfr+rFz2X/qGDMdEZv90/z/HTgtMvR4sOUTwza 3ftxCiCv12oo64I2Zae9wyBry6/Hwvos673ao= MIME-Version: 1.0 Received: by 10.43.44.69 with SMTP id uf5mr1354396icb.41.1330081777750; Fri, 24 Feb 2012 03:09:37 -0800 (PST) Received: by 10.42.224.132 with HTTP; Fri, 24 Feb 2012 03:09:37 -0800 (PST) In-Reply-To: <4F4752BB.20204@leichtgewicht.at> References: <4F4752BB.20204@leichtgewicht.at> Date: Fri, 24 Feb 2012 13:09:37 +0200 Message-ID: Subject: Re: [CODE] Short cleanup From: Left Right To: flex-dev@incubator.apache.org Content-Type: multipart/alternative; boundary=bcaec52e5f89e2941b04b9b3cb5b X-Virus-Checked: Checked by ClamAV on apache.org --bcaec52e5f89e2941b04b9b3cb5b Content-Type: text/plain; charset=ISO-8859-1 OMG!!! Seriously, you are writing SDK code and you don't know what's the difference between using `in' operator and calling a method defined on Object.prototype is? First of all, they are testing for different things. `in' is testing for a key in a collection, key may or may not be a property, for example, a key in the Dictionary is not a property. Object.prototype.hasOwnProperty() is a slow to resolve and slow to execute function that will resolve the property (which involves verifying access permissions and whether the enumeration of the property is allowed). It is on average 4 times slower then `in' if it is used to do the same thing. Further more, whilst `in' has several legitimate use cases (such as verifying whether the collection contains the key), Object.prototype.hasOwnProperty() is usually an indication that you are doing something wrong. For example, you did not define an interface to abstract different object types for similar access, or you created a blob class, you don't want to import because of too many dependencies - modular architecture failure. Further more, it isn't safe to use this function in mission-critical code, because someone can easily redefine it for __every__ object in the project, since it's defined on the prototype, and by redefining it may intercept some of your data you passed to this function. --bcaec52e5f89e2941b04b9b3cb5b--