From stdcxx-dev-return-2278-apmail-incubator-stdcxx-dev-archive=incubator.apache.org@incubator.apache.org Wed Oct 18 13:30:42 2006 Return-Path: Delivered-To: apmail-incubator-stdcxx-dev-archive@www.apache.org Received: (qmail 44960 invoked from network); 18 Oct 2006 13:30:42 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 18 Oct 2006 13:30:42 -0000 Received: (qmail 5580 invoked by uid 500); 18 Oct 2006 13:29:57 -0000 Delivered-To: apmail-incubator-stdcxx-dev-archive@incubator.apache.org Received: (qmail 5546 invoked by uid 500); 18 Oct 2006 13:29:57 -0000 Mailing-List: contact stdcxx-dev-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: stdcxx-dev@incubator.apache.org Delivered-To: mailing list stdcxx-dev@incubator.apache.org Received: (qmail 5470 invoked by uid 99); 18 Oct 2006 13:29:56 -0000 Received: from asf.osuosl.org (HELO asf.osuosl.org) (140.211.166.49) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 18 Oct 2006 06:29:56 -0700 X-ASF-Spam-Status: No, hits=0.0 required=10.0 tests= X-Spam-Check-By: apache.org Received-SPF: pass (asf.osuosl.org: local policy) Received: from [212.82.213.172] (HELO exkiv.kyiv.vdiweb.com) (212.82.213.172) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 18 Oct 2006 06:29:37 -0700 Received: from [10.11.37.198] ([10.11.37.198]) by exkiv.kyiv.vdiweb.com with Microsoft SMTPSVC(6.0.3790.1830); Wed, 18 Oct 2006 16:29:22 +0300 Message-ID: <45362C31.9020802@kyiv.vdiweb.com> Date: Wed, 18 Oct 2006 16:29:21 +0300 From: Farid Zaripov User-Agent: Thunderbird 1.5.0.7 (Windows/20060909) MIME-Version: 1.0 To: stdcxx-dev@incubator.apache.org Subject: RE: [PATCH] bitset.cc (STDCXX-297) Content-Type: multipart/mixed; boundary="------------050501080308070100090104" X-OriginalArrivalTime: 18 Oct 2006 13:29:22.0225 (UTC) FILETIME=[6C0C3A10:01C6F2B9] X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N --------------050501080308070100090104 Content-Type: text/plain; charset=KOI8-R; format=flowed Content-Transfer-Encoding: 7bit > -----Original Message----- > From: Martin Sebor [mailto:sebor@roguewave.com] > Sent: Wednesday, October 11, 2006 8:10 PM > To: stdcxx-dev@incubator.apache.org > Subject: Re: [PATCH] bitset.cc (STDCXX-297) > [...] > We could deal with it by having > two code paths, a faster one for power-of-2 CHAR_BIT values > and a slower one for the rare cases when it isn't (guarded by > suitable #if's). New patch is attached. Farid. --------------050501080308070100090104 Content-Type: text/plain; name="bitset.cc.diff" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="bitset.cc.diff" Index: bitset.cc =================================================================== --- bitset.cc (revision 465232) +++ bitset.cc (working copy) @@ -22,6 +22,29 @@ _RWSTD_NAMESPACE (__rw) { +#if 8 == _RWSTD_CHAR_BIT +# define _RWSTD_LOG2_CHAR_BITS 3 +#elif 16 == _RWSTD_CHAR_BIT +# define _RWSTD_LOG2_CHAR_BITS 4 +#elif 32 == _RWSTD_CHAR_BIT +# define _RWSTD_LOG2_CHAR_BITS 5 +#elif 64 == _RWSTD_CHAR_BIT +# define _RWSTD_LOG2_CHAR_BITS 6 +#endif + +#if 1 == _RWSTD_LONG_SIZE +# define _RWSTD_LOG2_LONG_SIZE 0 +#elif 2 == _RWSTD_LONG_SIZE +# define _RWSTD_LOG2_LONG_SIZE 1 +#elif 4 == _RWSTD_LONG_SIZE +# define _RWSTD_LOG2_LONG_SIZE 2 +#elif 8 == _RWSTD_LONG_SIZE +# define _RWSTD_LOG2_LONG_SIZE 3 +#elif 16 == _RWSTD_LONG_SIZE +# define _RWSTD_LOG2_LONG_SIZE 4 +#endif + + _EXPORT template void __rw_bitset (unsigned long *__bits, _RWSTD_SIZE_T __maxbits, @@ -51,9 +74,20 @@ __str += __pos; // compute the number of bytes occupied by `bits' +#if defined (_RWSTD_LOG2_CHAR_BITS) && defined (_RWSTD_LOG2_LONG_SIZE) + const _RWSTD_SIZE_T __nbytes = - (__maxbits + sizeof *__bits * _RWSTD_CHAR_BIT - 1) / _RWSTD_CHAR_BIT; + ((__maxbits >> (_RWSTD_LOG2_CHAR_BITS + _RWSTD_LOG2_LONG_SIZE)) + + (0 != (__maxbits & (__wordbits - 1)))) << _RWSTD_LOG2_LONG_SIZE; +#else // #if !defined (_RWSTD_LOG2_CHAR_BITS) || !defined (_RWSTD_LOG2_LONG_SIZE) + + const _RWSTD_SIZE_T __nbytes = + (__maxbits / __wordbits + (0 != __maxbits % __wordbits)) + * sizeof (*__bits); + +#endif // _RWSTD_LOG2_CHAR_BITS && _RWSTD_LOG2_LONG_SIZE + _RWSTD_MEMSET (__bits, 0, __nbytes); // set all bits but also check any extra characters as required @@ -74,7 +108,10 @@ } } +#undef _RWSTD_LOG2_CHAR_BITS +#undef _RWSTD_LOG2_ULONG_SIZE + _EXPORT template <_RWSTD_SIZE_T _Size, class _CharT, class _Traits> _STD::basic_istream<_CharT, _Traits>& --------------050501080308070100090104--