Return-Path: Delivered-To: apmail-harmony-dev-archive@www.apache.org Received: (qmail 95459 invoked from network); 16 Jan 2007 15:07:33 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 16 Jan 2007 15:07:33 -0000 Received: (qmail 74316 invoked by uid 500); 16 Jan 2007 15:07:36 -0000 Delivered-To: apmail-harmony-dev-archive@harmony.apache.org Received: (qmail 74276 invoked by uid 500); 16 Jan 2007 15:07:36 -0000 Mailing-List: contact dev-help@harmony.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@harmony.apache.org Delivered-To: mailing list dev@harmony.apache.org Received: (qmail 74267 invoked by uid 99); 16 Jan 2007 15:07:36 -0000 Received: from herse.apache.org (HELO herse.apache.org) (140.211.11.133) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 16 Jan 2007 07:07:36 -0800 X-ASF-Spam-Status: No, hits=-0.0 required=10.0 tests=SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (herse.apache.org: domain of wuyuehao@gmail.com designates 209.85.132.247 as permitted sender) Received: from [209.85.132.247] (HELO an-out-0708.google.com) (209.85.132.247) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 16 Jan 2007 07:07:27 -0800 Received: by an-out-0708.google.com with SMTP id b2so378126ana for ; Tue, 16 Jan 2007 07:07:06 -0800 (PST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=received:message-id:date:from:to:subject:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=j/ITqxihMifDOvIPDiWWF1QeVL5H+Me8sr0hgv74SULMia5BvAD+73TLvSzrZg5pSc4uib3f5Hi5khSvQRBm6vS7QCzh/8BZkqq0cflFR7HHi5hH7AoKbxsAdUX4oNm2SySX1+9p5BH5ougJdEe+38C6rFHNTFypFW1+TQAkZnw= Received: by 10.100.105.1 with SMTP id d1mr3182972anc.1168960026163; Tue, 16 Jan 2007 07:07:06 -0800 (PST) Received: by 10.70.54.17 with HTTP; Tue, 16 Jan 2007 07:07:05 -0800 (PST) Message-ID: <211709bc0701160707j3b453777l13294fbba6df0ae2@mail.gmail.com> Date: Tue, 16 Jan 2007 23:07:05 +0800 From: "Tony Wu" To: dev@harmony.apache.org Subject: Re: [classlib][performance]The case mapping operation could be simplify In-Reply-To: MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <211709bc0701150029h4c65b825yebe8f7d12bb729d9@mail.gmail.com> X-Virus-Checked: Checked by ClamAV on apache.org Thanks Paulex. I'll try to do this one by one if no one objects. On 1/15/07, Yang Paulex wrote: > 2007/1/15, Tony Wu : > > > > I found some String.toLower(Upper)Case are invoked in some place which > > is not necessay at all. > > > > As you know, String.toLower(Upper)Case will perform locale-sensitive > > mappings, context-sensitive mappings, and 1:M character mappings. It > > is expensive I think. > > > I think so, it needs to load locale data . > > In almost all of the conditions, following > > method[1] is good enough. > > > > > > For example, there is following line in java.net.URL, > > protocol = protocol.toLowerCase(); > > But according to RFC 2396, the scheme is defined by "alpha *( alpha | > > digit | "+" | "-" | "." )" > > > > And another example is the Locale, > > countryCode = country.toUpperCase(); > > But country code is defined as ASCII character only. > > > > So I'd like to add methods like [1] to org.apache.harmony.luni.util > > and refactor every possible place to use it. please correct me if I am > > wrong, any concerns are welcome. > > > > [1] > > public static String toLowerCase(String s){ > > StringBuffer buffer = new StringBuffer(); > > for (int i = 0; i < s.length(); i++) { > > char c = s.charAt(i); > > if ('A' <= c && c <= 'Z') { > > buffer.append((char) (c + ('a' - 'A'))); > > }else{ > > buffer.append(c); > > } > > } > > return buffer.toString(); > > } > > > Sounds good, but please add clear comments to this method and the > invocations why String.toLowerCase is not preferred in these cases. > > -- > > Tony Wu > > China Software Development Lab, IBM > > > > > > -- > Paulex Yang > China Software Development Labotary > IBM > > -- Tony Wu China Software Development Lab, IBM