Return-Path: X-Original-To: apmail-tomcat-dev-archive@www.apache.org Delivered-To: apmail-tomcat-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 BC1D81006E for ; Sat, 15 Jun 2013 15:40:44 +0000 (UTC) Received: (qmail 49922 invoked by uid 500); 15 Jun 2013 15:40:43 -0000 Delivered-To: apmail-tomcat-dev-archive@tomcat.apache.org Received: (qmail 49664 invoked by uid 500); 15 Jun 2013 15:40:43 -0000 Mailing-List: contact dev-help@tomcat.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: "Tomcat Developers List" Delivered-To: mailing list dev@tomcat.apache.org Received: (qmail 49449 invoked by uid 99); 15 Jun 2013 15:40:42 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 15 Jun 2013 15:40:42 +0000 X-ASF-Spam-Status: No, hits=0.0 required=5.0 tests=RCVD_IN_DNSWL_NONE X-Spam-Check-By: apache.org Received-SPF: error (nike.apache.org: local policy) Received: from [76.96.62.17] (HELO qmta10.westchester.pa.mail.comcast.net) (76.96.62.17) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 15 Jun 2013 15:40:34 +0000 Received: from omta06.westchester.pa.mail.comcast.net ([76.96.62.51]) by qmta10.westchester.pa.mail.comcast.net with comcast id oeSB1l00316LCl05AffsQS; Sat, 15 Jun 2013 15:39:52 +0000 Received: from Christophers-MacBook-Pro.local ([69.143.106.98]) by omta06.westchester.pa.mail.comcast.net with comcast id offs1l00D27QCxh3SffsBG; Sat, 15 Jun 2013 15:39:52 +0000 Message-ID: <51BC8AC4.5010004@christopherschultz.net> Date: Sat, 15 Jun 2013 11:39:48 -0400 From: Christopher Schultz User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:17.0) Gecko/20130509 Thunderbird/17.0.6 MIME-Version: 1.0 To: Tomcat Developers List Subject: MD5Encoder.encode versus HexUtils.toHexString X-Enigmail-Version: 1.5.1 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="----enig2TDHADOTNCVGXCJJBQHSB" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=comcast.net; s=q20121106; t=1371310792; bh=p6gIPYetUN0geOCKwEvG7FoTWWhiNvqvuBu2FBI0e90=; h=Received:Received:Message-ID:Date:From:MIME-Version:To:Subject: Content-Type; b=bmlHmv8uDfczZUjiyDV6xXFKCUFk5WECS6TSCqsfHT7ISTyFA7LCcGfz0aqU2zk0P qvOlrNQ59k5UwvIFx5alJK0ReRaQ5/dfjkiddJr2mVLopRg4MuvlHBS8VhkqyboEsn PJbQ+KvMQjZemeLen95aDGq3HDf8z8rilPsNC5J9gk8fen1QLvz90ZY+RXmgjfbe80 Ua3xkVN3Z7qv4EJU9YUJ6ZS6PVF91Nv+WxzsqTrSfXIA/77flf2f3kmIBXTb1tkR/j nQoEgFrHCnx09yUvpdS0Ll4Syi7Bdrqxd3clkpXAVS6Ia0LFECgZr1U0Yry2bdnGBs rENxTeMWlkenw== X-Virus-Checked: Checked by ClamAV on apache.org ------enig2TDHADOTNCVGXCJJBQHSB Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable All, While looking into a patch for BasicRealm, I noticed that there are two classes that convert byte[] to a hex-encoded string (e.g. byte[] { 1, 2, a, b ] -> "12ab"): HexUtils and MD5Encoder. MD5Encoder only has a single method (encode) and it does exactly what HexUtils.toHexString does, except that it only works for exactly 16-byte arrays. I haven't actually written any performance tests, but looking at the code it seems that HexUtils.toHexString would execute slightly faster for a 16-byte array because of repeated integer multiplication in the loo= p. Is there a reason for MD5Encoder to exist? It appears only to be used in the following classes: RealmBase DigestAuthenticator WebdavServlet Although I suppose a specialty 16-byte-only method might be written to be slightly faster than the general-purpose HexUtils.toHexString method, I'm not sure it's worth having a separate class/method to do it. Any objections to using HexUtils.toHexString uniformly and removing the MD5Encoder class entirely? Thanks, -chris ------enig2TDHADOTNCVGXCJJBQHSB Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG/MacGPG2 v2.0.17 (Darwin) Comment: GPGTools - http://gpgtools.org Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iQIcBAEBCAAGBQJRvIrGAAoJEBzwKT+lPKRYxecP/Roj6RLJ6dc917bJAvJcXs2a yx9PS6SmvIYWGAb/gJuTAChXaVq/2L3Ct74B6qjKUsEoZxUycXR+c21tfev/Qp+9 CGbt/cgf4sjUsxsODubZdiO/JOxILIJ4RPbQQW1ZpXJZOtm/4+gW0/5hxoJYlK9U V2MHnE3Cu/NgpUbx+BYDjMPw4N8b7jf/1NA6rPjtPECVRLAvou6wmWT3AeQJnFrO 0BI3eFOX0KGeXMhtW+uMnCJT7hJQ3YGAVdqsYiwecJsZvWTvrlu0arTuDzN3X+1o oB9KSg5QMhHHU4U+Qm0x6ywHzdtDA64VnKbz6984fZ1QMuL1SiXieDDBTQ48hcvI MpVVkn1irMS4QNfQO9+PX6+22NPNdr+YTtVg6jQr0+nibQMI/5coLG9ymJ5zGCW1 6X2UpMqsnuk+QZM4e8hT+lsR6X03mFtp6e/K5SKjopzJcBG5rapH9aPjKz6C+J8D y1bblk8V6CyVIIuzfB6wGYnAwUD0BScq3n2EKP70a0qJAlbLAVG0EWNMuDcfwS53 pCbS0E33foCLxOHvj+vQ9P/bu5ReZ/6MOuMUycj3yKqzVS6nBJm4YOy34zdnFOUg IR0cksBqHmlmhoenEYIFsp4oixiaajuxjI636G8aX0KKmGZsaED7dPTBeRY+5669 HmvJONWFTq4gmOrh7ZC6 =Uyi6 -----END PGP SIGNATURE----- ------enig2TDHADOTNCVGXCJJBQHSB--