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 E97CB10FA8 for ; Thu, 14 Nov 2013 08:08:54 +0000 (UTC) Received: (qmail 23103 invoked by uid 500); 14 Nov 2013 08:08:29 -0000 Delivered-To: apmail-flex-dev-archive@flex.apache.org Received: (qmail 23019 invoked by uid 500); 14 Nov 2013 08:08:22 -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 22984 invoked by uid 99); 14 Nov 2013 08:08:18 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 14 Nov 2013 08:08:18 +0000 X-ASF-Spam-Status: No, hits=1.0 required=5.0 tests=FRT_ADOBE2,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of maurice.amsellem@systar.com designates 66.129.85.153 as permitted sender) Received: from [66.129.85.153] (HELO smtp02.myhostedservice.com) (66.129.85.153) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 14 Nov 2013 08:08:12 +0000 Received: from EXHUB04.netplexity.local (172.29.211.24) by smtp02.myhostedservice.com (172.29.211.12) with Microsoft SMTP Server (TLS) id 14.2.347.0; Thu, 14 Nov 2013 03:07:47 -0500 Received: from EXMBX05.netplexity.local ([fe80::cc58:cfe7:ba3b:fae]) by exhub04 ([172.29.211.24]) with mapi id 14.03.0146.000; Thu, 14 Nov 2013 03:07:50 -0500 From: Maurice Amsellem To: "dev@flex.apache.org" Subject: RE: Question on StringUtil.trim Thread-Topic: Question on StringUtil.trim Thread-Index: AQHO4Q/zAJOnAHIUSGa6vvQ22X8yZZokXolQ Date: Thu, 14 Nov 2013 08:07:50 +0000 Message-ID: <2095F5EBE04D59409DFCE91FFCEBF7AF3F5483CF@EXMBX05.netplexity.local> References: <3906BA9F-BC6C-4F91-9CED-7D6C8E885901@ubik-ingenierie.com> In-Reply-To: <3906BA9F-BC6C-4F91-9CED-7D6C8E885901@ubik-ingenierie.com> Accept-Language: fr-FR, en-US Content-Language: fr-FR X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [172.29.211.31] Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-Virus-Checked: Checked by ClamAV on apache.org Thanks Benoit. So it's slice that does the optimization. Maurice -----Message d'origine----- De=A0: Benoit Wiart [mailto:b.wiart@ubik-ingenierie.com]=20 Envoy=E9=A0: jeudi 14 novembre 2013 09:03 =C0=A0: dev@flex.apache.org Objet=A0: Re: Question on StringUtil.trim I had the same question a few weeks ago And I think the fash sdk is optimized in this case as Scout didn't report a= ny memory allocation Le 14 nov. 2013 =E0 05:33, Alex Harui a =E9crit : >=20 >=20 > On 11/13/13 8:23 PM, "labriola@digitalprimates.net" > wrote: >=20 >>> No idea. I was trying to think of any danger of manipulating the=20 >>> returned string if it is the original and not always a copy, but I=20 >>> can't think of anything off-hand. >>=20 >>> Is it much faster to add the check and return the original? >>=20 >>=20 >> Aren't AS strings immutable anyway? So, the method got a copy to=20 >> begin with from the stack, but it is always a copy so, if the check=20 >> is any faster, returning the original shouldn't be able to cause an issu= e. > I don't really know how it works. I think Strings are effectively=20 > immutable because there is no "in-place" manipulation APIs (no setCharAt)= . > I don't think you get a copy on the stack, but I could be wrong, I=20 > thought you just got the pointer/reference, but someone could verify=20 > that with a profiler. I also don't know if there is a quick check=20 > inside String.slice that returns the original if the indexes indicate=20 > the entire string. >=20 > -Alex >=20