From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 10381 invoked by alias); 22 Apr 2015 20:11:43 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 10364 invoked by uid 89); 22 Apr 2015 20:11:42 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.6 required=5.0 tests=AWL,BAYES_00,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW,SPF_PASS autolearn=ham version=3.3.2 X-Spam-User: qpsmtpd, 2 recipients X-HELO: mail-wg0-f53.google.com Received: from mail-wg0-f53.google.com (HELO mail-wg0-f53.google.com) (74.125.82.53) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-GCM-SHA256 encrypted) ESMTPS; Wed, 22 Apr 2015 20:11:41 +0000 Received: by wgso17 with SMTP id o17so258981504wgs.1; Wed, 22 Apr 2015 13:11:38 -0700 (PDT) X-Received: by 10.180.14.134 with SMTP id p6mr8981757wic.44.1429733498701; Wed, 22 Apr 2015 13:11:38 -0700 (PDT) Received: from [192.168.0.22] (arf62-1-82-237-250-248.fbx.proxad.net. [82.237.250.248]) by mx.google.com with ESMTPSA id bx3sm8758783wjc.21.2015.04.22.13.11.37 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 22 Apr 2015 13:11:37 -0700 (PDT) Message-ID: <55380079.3000105@gmail.com> Date: Wed, 22 Apr 2015 20:11:00 -0000 From: =?UTF-8?B?RnJhbsOnb2lzIER1bW9udA==?= User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.6.0 MIME-Version: 1.0 To: "libstdc++@gcc.gnu.org" , gcc-patches Subject: Re: Hide _S_n_primes from user code References: <5537F904.4010405@gmail.com> In-Reply-To: <5537F904.4010405@gmail.com> Content-Type: multipart/mixed; boundary="------------020001090703080308020501" X-SW-Source: 2015-04/txt/msg01360.txt.bz2 This is a multi-part message in MIME format. --------------020001090703080308020501 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Content-length: 555 With the patch this time. On 22/04/2015 21:39, François Dumont wrote: > Hello > > Here is a rather trivial patch, just code cleanup. Since we export > _Prime_rehash_policy we do not need to expose the _S_n_primes anymore. > > * include/bits/hashtable_policy.h > (_Prime_rehash_policy::_S_n_primes): > Delete. > * src/c++11/hashtable_c++0x.cc (_Prime_rehash_policy::_M_next_bkt): > Remove usage of latter and compute size of the prime numbers array > locally. > > Tested under Linux x86_64. > > Ok to commit ? > > François > --------------020001090703080308020501 Content-Type: text/x-patch; name="hashtable.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="hashtable.patch" Content-length: 1215 diff --git a/libstdc++-v3/include/bits/hashtable_policy.h b/libstdc++-v3/include/bits/hashtable_policy.h index 14bcca6..a9ad7dd 100644 --- a/libstdc++-v3/include/bits/hashtable_policy.h +++ b/libstdc++-v3/include/bits/hashtable_policy.h @@ -495,8 +495,6 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION _M_reset(_State __state) { _M_next_resize = __state; } - enum { _S_n_primes = sizeof(unsigned long) != 8 ? 256 : 256 + 48 }; - static const std::size_t _S_growth_factor = 2; float _M_max_load_factor; diff --git a/libstdc++-v3/src/c++11/hashtable_c++0x.cc b/libstdc++-v3/src/c++11/hashtable_c++0x.cc index 22de51b..69f999f 100644 --- a/libstdc++-v3/src/c++11/hashtable_c++0x.cc +++ b/libstdc++-v3/src/c++11/hashtable_c++0x.cc @@ -56,8 +56,10 @@ namespace __detail return __fast_bkt[__n]; } + constexpr auto __n_primes + = sizeof(__prime_list) / sizeof(unsigned long) - 1; const unsigned long* __next_bkt = - std::lower_bound(__prime_list + 5, __prime_list + _S_n_primes, __n); + std::lower_bound(__prime_list + 5, __prime_list + __n_primes, __n); _M_next_resize = __builtin_ceil(*__next_bkt * (long double)_M_max_load_factor); return *__next_bkt; --------------020001090703080308020501--