From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.120]) by sourceware.org (Postfix) with ESMTP id D327B38754A7 for ; Fri, 17 Jul 2020 09:43:04 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org D327B38754A7 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-106-PsJZwElWOaeRhubaL-Wovw-1; Fri, 17 Jul 2020 05:43:02 -0400 X-MC-Unique: PsJZwElWOaeRhubaL-Wovw-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id EEBA2108E; Fri, 17 Jul 2020 09:43:01 +0000 (UTC) Received: from localhost (unknown [10.33.37.45]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9CB1E5C1D3; Fri, 17 Jul 2020 09:43:01 +0000 (UTC) Date: Fri, 17 Jul 2020 10:43:00 +0100 From: Jonathan Wakely To: =?iso-8859-1?Q?Fran=E7ois?= Dumont Cc: "libstdc++@gcc.gnu.org" , gcc-patches Subject: Re: [PATCH][Hashtable 2/6] Avoid over-sizing container Message-ID: <20200717094300.GJ4137376@redhat.com> References: MIME-Version: 1.0 In-Reply-To: X-Clacks-Overhead: GNU Terry Pratchett X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=iso-8859-1; format=flowed Content-Transfer-Encoding: 8bit Content-Disposition: inline X-Spam-Status: No, score=-9.9 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: libstdc++@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libstdc++ mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 17 Jul 2020 09:43:06 -0000 On 17/11/19 21:56 +0100, François Dumont wrote: >This patch avoids over-sizing of the container by rather considering >the bucket count hint or potential reservation. > >It concerns only the non-multi containers. > >    * include/bits/hashtable.h >    (_Hashtable<>(_InputIterator, _InputIterator, size_t, const _H1&, >    const _H2&, const _Hash&, const _Equal&, const _ExtractKey&, >    const allocator_type&, __unique_keys_t)): New. >    (_Hashtable<>(_InputIterator, _InputIterator, size_t, const _H1&, >    const _H2&, const _Hash&, const _Equal&, const _ExtractKey&, >    const allocator_type&, __multi_keys_t)): New. >    (_Hashtable<>(_InputIterator, _InputIterator, size_t, const _H1&, >    const _H2&, const _Hash&, const _Equal&, const _ExtractKey&, >    const allocator_type&)): Delegate to latters. >    (operator=(initializer_list)): Rehash if too small. >    (_M_insert(_Arg&&, const _NodeGenerator&, __unique_keys_t)): Remove >    size_t len parameter. >    * include/bits/hashtable_policy.h (_Insert_base<>::_M_insert_range): >    Do not try to get input range distance. >    * testsuite/23_containers/unordered_set/cons/bucket_hint.cc: New. >    * testsuite/23_containers/unordered_set/modifiers/insert.cc: New. > >Tested under Linux x86_64. OK for master. Please update the copyright years in the new tests (sorry it took so long to review it!)