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 098699F7A for ; Fri, 13 Jan 2012 10:32:54 +0000 (UTC) Received: (qmail 71530 invoked by uid 500); 13 Jan 2012 10:29:33 -0000 Delivered-To: apmail-incubator-flex-dev-archive@incubator.apache.org Received: (qmail 71349 invoked by uid 500); 13 Jan 2012 10:29:25 -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 71312 invoked by uid 99); 13 Jan 2012 10:29:24 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 13 Jan 2012 10:29:24 +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 (athena.apache.org: domain of joaopedromartinsfernandes@gmail.com designates 74.125.82.41 as permitted sender) Received: from [74.125.82.41] (HELO mail-ww0-f41.google.com) (74.125.82.41) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 13 Jan 2012 10:29:18 +0000 Received: by wgbed3 with SMTP id ed3so1328152wgb.0 for ; Fri, 13 Jan 2012 02:28:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:from:date:message-id:subject:to:content-type; bh=vP2qYypHPVtcHNqD3qhlsThqsYpAMifdLqQXZuQXvUk=; b=SUQWWYANPys2x1SbW8oTfILRQUxKRRusDNR8cBL7ZB11vmFDsS5Aao8QN0t5dIAqtX 3nV3W7fi9Pk6uQbW55oEVp+EttceciOgLf5ASVzX3K+6MW3SmDXd07x4l7I/i9+NjPIZ inaZdh/9KGWMk8a2Qh45R7xkQw/a8/WNSBXzQ= Received: by 10.180.94.97 with SMTP id db1mr434995wib.16.1326450537230; Fri, 13 Jan 2012 02:28:57 -0800 (PST) MIME-Version: 1.0 Received: by 10.216.142.41 with HTTP; Fri, 13 Jan 2012 02:28:36 -0800 (PST) From: =?ISO-8859-1?Q?Jo=E3o_Fernandes?= Date: Fri, 13 Jan 2012 10:28:36 +0000 Message-ID: Subject: Compiler optimization for getter/setter To: flex-dev@incubator.apache.org Content-Type: multipart/alternative; boundary=f46d0442681a15712704b66655eb --f46d0442681a15712704b66655eb Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Hi, I know that the code is not available yet but something that bugs me currently in the compiler is what is generated for getters and setters Currently a public variable x will be generated as: [Bindable(event=3D"propertyChange")] public function get x():int { return this._105x; } public function set x(value:int):void { var oldValue:Object=3Dthis._105x; if (oldValue !=3D=3D value) { this._105x=3Dvalue; if (this.hasEventListener("propertyChange")) this.dispatchEvent(mx.events.PropertyChangeEvent.createUpdateEvent(this, "x", oldValue, value)); } } the problem with this approach is that each time 1 property in that class is changed and dispatches the propertyChangeEvent which forces all getters to be re-evaluated. What I'm proposing is that the compiler generates like this [Bindable(event=3D"xChange")] public function get x():int { return this._105x; } public function set x(value:int):void { var oldValue:Object=3Dthis._105x; if (oldValue !=3D=3D value) { this._105x=3Dvalue; if (this.hasEventListener("xChange")) this.dispatchEvent(new Event("xChange")); if (this.hasEventListener("propertyChange")) this.dispatchEvent(mx.events.PropertyChangeEvent.createUpdateEvent(this, "x", oldValue, value)); } } dispatching the 2 events, the first will allow the x getter to be called without requiring all possible getters to be triggered and the propertyChangeEvent will allow to keep compatibility with all the collections that depend on that event to notify that a property on a value object has changed. I'm not sure if dispatching a second event will be "heavy" but considering a large number of bindable properties that some classes can have, evaluating all the getters might be way heavier. Does this seem a candidate for a patch in the compiler or does anyone see any drawback from this approach that I'm not considering? --=20 Jo=E3o Fernandes --f46d0442681a15712704b66655eb--