Return-Path: Delivered-To: apmail-harmony-dev-archive@www.apache.org Received: (qmail 81375 invoked from network); 15 Jan 2007 08:43:32 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 15 Jan 2007 08:43:32 -0000 Received: (qmail 8805 invoked by uid 500); 15 Jan 2007 08:43:37 -0000 Delivered-To: apmail-harmony-dev-archive@harmony.apache.org Received: (qmail 8520 invoked by uid 500); 15 Jan 2007 08:43: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 8511 invoked by uid 99); 15 Jan 2007 08:43:36 -0000 Received: from herse.apache.org (HELO herse.apache.org) (140.211.11.133) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 15 Jan 2007 00:43:36 -0800 X-ASF-Spam-Status: No, hits=2.0 required=10.0 tests=HTML_MESSAGE,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (herse.apache.org: domain of paulex.yang@gmail.com designates 64.233.182.186 as permitted sender) Received: from [64.233.182.186] (HELO nf-out-0910.google.com) (64.233.182.186) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 15 Jan 2007 00:43:27 -0800 Received: by nf-out-0910.google.com with SMTP id a4so2090838nfc for ; Mon, 15 Jan 2007 00:43: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:references; b=Q5FYjUFeht+C74ZMeToYGoFVibT4Eg1vvuRsAPf668Ya2DSUxsRwwnp8AgR8f/c9J8T57wAvQriMcp1yl5jIAyxr4QJkc3sFXms8PJXgm3IgC23sIPpksbTqRZulJkDXJAKqxO5FWFFz5+nVhBEjMz8vtpz9YnH+vOK6OYI/LdE= Received: by 10.49.19.18 with SMTP id w18mr3932398nfi.1168850585684; Mon, 15 Jan 2007 00:43:05 -0800 (PST) Received: by 10.49.14.20 with HTTP; Mon, 15 Jan 2007 00:43:05 -0800 (PST) Message-ID: Date: Mon, 15 Jan 2007 16:43:05 +0800 From: "Yang Paulex" To: dev@harmony.apache.org Subject: Re: [classlib][performance]The case mapping operation could be simplify In-Reply-To: <211709bc0701150029h4c65b825yebe8f7d12bb729d9@mail.gmail.com> MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_Part_192382_4386969.1168850585647" References: <211709bc0701150029h4c65b825yebe8f7d12bb729d9@mail.gmail.com> X-Virus-Checked: Checked by ClamAV on apache.org ------=_Part_192382_4386969.1168850585647 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline 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 ------=_Part_192382_4386969.1168850585647--