From patchwork Mon Jun 10 04:37:43 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Fran=C3=A7ois_Dumont?= X-Patchwork-Id: 1945638 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20230601 header.b=ThhElNMi; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=server2.sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=patchwork.ozlabs.org) Received: from server2.sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4VyJvw4KnGz20V0 for ; Mon, 10 Jun 2024 14:38:19 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 9BE2F385842A for ; Mon, 10 Jun 2024 04:38:08 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-wr1-x42f.google.com (mail-wr1-x42f.google.com [IPv6:2a00:1450:4864:20::42f]) by sourceware.org (Postfix) with ESMTPS id 117793858D26; Mon, 10 Jun 2024 04:37:48 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 117793858D26 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 117793858D26 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::42f ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1717994270; cv=none; b=qEfXb+i0+4IDuzWTjvN8lgJKUxNtudrPWBqctfB/MDhHxzYOAC3sFyZ67Im7prCzg776FtnNsbeoWommLhxa9yN24ZLPIZbjSffPEo+c6VkqpsKXJY3SAVklQD2GTXA352TATa5Q4HVY/OaHaItrvrn/tFrFj6h+x820Qhoy6KQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1717994270; c=relaxed/simple; bh=c6WNjFYJCHi0gSCDy/YpTWtHC8oYmloCTCuzLirZ08s=; h=DKIM-Signature:Message-ID:Date:MIME-Version:To:From:Subject; b=FXtM8NbDPoldYVgve1EuINNtE/aswZY6y5QHf1Zbi4jXEXo2AzNrmSv5wBVbG/kqL4vtDHMu5+Nry5tdNJVVxfDoRmn0J7pab1vj874v8wVVbQT7yume3KK2e0lPwCqrWWmzkYC2ao6Y3epzNYzCGtAIlaS11WBAqnyrpkadGiA= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-wr1-x42f.google.com with SMTP id ffacd0b85a97d-35f1a7386d5so959831f8f.3; Sun, 09 Jun 2024 21:37:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1717994266; x=1718599066; darn=gcc.gnu.org; h=subject:from:cc:to:content-language:user-agent:mime-version:date :message-id:from:to:cc:subject:date:message-id:reply-to; bh=c6WNjFYJCHi0gSCDy/YpTWtHC8oYmloCTCuzLirZ08s=; b=ThhElNMi/QvqSNpAFcBm/UCWoROAQvY9Z6Tv9fzR3G7ijLB7HhwsaANJs7t3WL+XMJ U8OWj49hok19O6ynLEsUoWFdHuaggjEqEoWGtkJKDtecFHu4QuVCJKu15kxLYzPn008G LP9ZRkky6wC9/mSKQPZgl7SNtWKlylHgYVj0km6yS5kbDR4EwhTYAC2lmZe1P15TdMVs faqLFXD5uSxDKpSvmkimbjRMYMguLR5VvlQBgevwsnmPbehgAgFr2kmaYH9+zGkt3P0/ nXcFd1Q+Dt0szkN9E4MGcoBg0IZjgo6Z/gDaj12EdTMcItIlFpGUYhMCyh0bsbUYufT2 +wpg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717994266; x=1718599066; h=subject:from:cc:to:content-language:user-agent:mime-version:date :message-id:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=c6WNjFYJCHi0gSCDy/YpTWtHC8oYmloCTCuzLirZ08s=; b=GxSgX5HTC2xmjRyc06aKPIyVV2tkFl+3zZq8I2rLX8lcIYgFTppn8oeqjoxu/bTXiK Wm+C8RAKUn0CMq6cllKReUmQe50+DfPWJFybdj+qceLreqpyLlxR8EXtiEecn7jlkotI lSoqmIVHCXgK3DrMjoehHWwWnYevWRs0Rijf583XrlCMKlu7M4r4xHqwrgFRAAUjM+SJ wUHZKie7xycvKExuw5Khd9PQWQclQpcY7Al75lWkBJvbsExLDnk9jY2ez1bOUsMV/A0g rF/+nc0tJqz64FMVhVnDR7CV9+o2fS+rY2juF2ttFQH/yJGfHZZnroWaXCTiu3xRbLiN mYBg== X-Gm-Message-State: AOJu0YwfV2ndpiwq3QNX4ypssuGb7nbKB/Udb4UEZLj7uLfrgVVB351g Np5cpNFt7tkhWBx+4WivupgY0JAow49jX3YOeVmg5v2dspbvJ9XcEZKZfg== X-Google-Smtp-Source: AGHT+IENOcFtLHRRjE4qNcnI8l53VOEjonSodGORpUurbRbqeFdZTKj4GMbPk6SfXq84Ypm5qYwCDA== X-Received: by 2002:a05:6000:511:b0:355:230:e2d3 with SMTP id ffacd0b85a97d-35efed3f914mr5621153f8f.20.1717994265648; Sun, 09 Jun 2024 21:37:45 -0700 (PDT) Received: from [10.68.0.75] ([89.207.171.135]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-35ef5d293f6sm9866735f8f.12.2024.06.09.21.37.44 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sun, 09 Jun 2024 21:37:44 -0700 (PDT) Message-ID: <6aa18081-cde2-48f8-b426-5127e32b1bec@gmail.com> Date: Mon, 10 Jun 2024 06:37:43 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Content-Language: en-US To: libstdc++ Cc: gcc-patches From: =?utf-8?q?Fran=C3=A7ois_Dumont?= Subject: [_Hashtable] Optimize destructor X-Spam-Status: No, score=-11.2 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org Hi libstdc++: [_Hashtable] Optimize destructor Hashtable destructor do not need to call clear() method that in addition to destroying all nodes also reset all buckets to nullptr. libstdc++-v3/ChangeLog:     * include/bits/hashtable.h (~_Hashtable()): Replace clear call with     a _M_deallocate_nodes call. Tested under Linux x64, ok to commit ? François diff --git a/libstdc++-v3/include/bits/hashtable.h b/libstdc++-v3/include/bits/hashtable.h index e8e51714d72..45b232111da 100644 --- a/libstdc++-v3/include/bits/hashtable.h +++ b/libstdc++-v3/include/bits/hashtable.h @@ -1666,7 +1666,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION "Cache the hash code or qualify your functors involved" " in hash code and bucket index computation with noexcept"); - clear(); + this->_M_deallocate_nodes(_M_begin()); _M_deallocate_buckets(); }