Return-Path: X-Original-To: apmail-hc-dev-archive@www.apache.org Delivered-To: apmail-hc-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 E4BA0D0AA for ; Mon, 11 Feb 2013 18:15:11 +0000 (UTC) Received: (qmail 80908 invoked by uid 500); 11 Feb 2013 18:15:11 -0000 Delivered-To: apmail-hc-dev-archive@hc.apache.org Received: (qmail 80864 invoked by uid 500); 11 Feb 2013 18:15:11 -0000 Mailing-List: contact dev-help@hc.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: "HttpComponents Project" Delivered-To: mailing list dev@hc.apache.org Received: (qmail 80856 invoked by uid 99); 11 Feb 2013 18:15:11 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 11 Feb 2013 18:15:11 +0000 X-ASF-Spam-Status: No, hits=-0.7 required=5.0 tests=RCVD_IN_DNSWL_LOW,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of sebbaz@gmail.com designates 209.85.212.174 as permitted sender) Received: from [209.85.212.174] (HELO mail-wi0-f174.google.com) (209.85.212.174) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 11 Feb 2013 18:15:04 +0000 Received: by mail-wi0-f174.google.com with SMTP id hi8so3481974wib.13 for ; Mon, 11 Feb 2013 10:14:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:x-received:in-reply-to:references:date:message-id :subject:from:to:content-type; bh=8NbjFNAIj2+a1zOLxY8hHqL4PcJHXcNLsZGkDSh8xsw=; b=EuCeoFM2g9+3BZh5XJPwXPQ379DHit1hC4TARiUXePA9cVYOKx+PCYMb2PH936aTD0 DEx7D3pdBbvpNDzSySq743nQ98B3nFLUb6sJrBqnGtcHkfjefVVXjLYSgzQuItyp7vf0 2cv2VrlrJPPfB4m/mYREOBQjNRKhpDpyOLemPKN+B7RdP3phB3U8x/fG8CGsuJNOwMBm 1P48xwCXT6LIEFX/0eP0RkInm2BO/Kn+7FLDIQZtCGdB7kBrUx9IxKCK8wBDVZEeCDD1 WlrXCAFuXlEcjTvYBxYnGWKl251+MN3/qUAYtg5zDtUfspiqYGNFQh85FHe1+Eg2pH5V jk4Q== MIME-Version: 1.0 X-Received: by 10.180.8.4 with SMTP id n4mr17821126wia.13.1360606473845; Mon, 11 Feb 2013 10:14:33 -0800 (PST) Received: by 10.194.61.236 with HTTP; Mon, 11 Feb 2013 10:14:33 -0800 (PST) In-Reply-To: <1360587911.1752.10.camel@ubuntu> References: <1360587911.1752.10.camel@ubuntu> Date: Mon, 11 Feb 2013 18:14:33 +0000 Message-ID: Subject: Re: InetAddressUtils - use of non-capturing groups From: sebb To: HttpComponents Project Content-Type: text/plain; charset=ISO-8859-1 X-Virus-Checked: Checked by ClamAV on apache.org On 11 February 2013 13:05, Oleg Kalnichevski wrote: > On Mon, 2013-02-11 at 12:24 +0000, sebb wrote: >> The IPv6 regexes use non-capturing groups - i.e. (?:pattern) - whereas >> the IPV4 pattern uses capturing groups - i.e. (pattern). >> >> Just wondering why they don't all use non-capturing groups, given that >> the patterns are only used in boolean matches() methods? >> > > No reason. Just me being sloppy. > >> If it more efficient to use non-capturing groups, perhaps they should >> be use throughout? >> >> If efficiency is not a concern, then the IPv6 patterns would be easier >> to read if they used non-capturing groups, as that would mean the >> colon would only appear as itself rather than sometimes as itself and >> sometimes as part of (?:pattern). In some cases the pattern begins >> with : which looks odd. >> > > I think we should strive for simplicity over efficiency here. These > regular expressions are already too complex for mere mortals. Anything > that would make them more readable would be a good thing. In which case, would you be OK if I extracted the common sections out? For example, [0-9A-Fa-f]{1,4} appears several times; it could be defined as IPV6_HEX_FIELD and then used to build up the other strings. AFAIK, javac concatenates strings at compile time if they are constants, so it would be no less efficient. > Oleg > > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org > For additional commands, e-mail: dev-help@hc.apache.org > --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org For additional commands, e-mail: dev-help@hc.apache.org