From patchwork Mon Dec 18 08:36:37 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Martin_K=C3=BCttler?= X-Patchwork-Id: 180209 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:24d3:b0:fb:cd0c:d3e with SMTP id r19csp1108066dyi; Mon, 18 Dec 2023 00:50:23 -0800 (PST) X-Google-Smtp-Source: AGHT+IHNEfDZyexpAztiYOoJLsQo/7zxe4U9NEsH/7k4hOgX7CNsPstCHUZf80J5h0S+liLaVtfo X-Received: by 2002:a0c:c48d:0:b0:67a:a5c3:8110 with SMTP id u13-20020a0cc48d000000b0067aa5c38110mr16242559qvi.3.1702889422848; Mon, 18 Dec 2023 00:50:22 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1702889422; cv=pass; d=google.com; s=arc-20160816; b=pv14SorUNIdxHi6STl8lUr9tm67jd1xNcgAHHRWqgAXn0aGLKnW9PD2H6uxo+sdFOO P36ParRRZdz8Z5Y+ECLyCDFteWXrXeu+Ev1JtZgQu6+uUI5cAzNI/QqgBMIMNN4De+CH u8YxhG3zUe6lJmpgeVDCEsQex6sj7rqtquVIl+Z6JnlR/eeJPc40mW8rE/1tUdOLNpHJ pgDFd2exUZ85pA09KJ4QgfSNh+4VYiexxYp4/vXswrbc7DcLMASPbCb8dDXGdzHrY/ZV HKSFrBS2+w7Dh9tzTrZKnDB8EPxRO9sDar+SqcWSgbWGWAYnF3s93c3jyIGeK7OpyG1a szbA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:mime-version:message-id:date :subject:to:from:user-agent:dkim-signature:arc-filter:dmarc-filter :delivered-to; bh=4w4irFjMsSBB1LCR34Et6ZwO2Y6rqvw+W1RKIdVVunQ=; fh=hPrbWPhweUx4V0GV9uXJqbyAzg2ABmTz7kczrAQqMmM=; b=eox265esaTv3PBBRQID0gj43OEAUdm0/Cz0KxElWBU7VhyDzYPdf3fOB4dIA+kGfMi iEoB3aaYLART/qfEMyzCFv8SiyMb67lA4ItSjcvtaAk/sT6Lc50qtCX203p+BGWJEE/x TcoKR6dP/HIl0PJhFpUbLI1ZMEu5HEKGs3XVS3mue/TbR4Dw8nrUX/+BI/Wxl/979jYq bGWdyQv4M663aaRppjmYGDjT3PTof9BjSjwcirlU9QjuWNTZKMAGSUI0sayA1YLacz2x 7z/VKCyyO+ws57WokBN+npA9pd3cpPtnzlzrhbl7/VMHkJG9Zg5iY3KbuUoqvMdJBI57 8v8w== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernkonzept.com header.s=mx1 header.b=Gkxvo6FG; arc=pass (i=1); spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernkonzept.com Received: from server2.sourceware.org (server2.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id b8-20020a0ccd08000000b0067f44ac7a42si1689717qvm.348.2023.12.18.00.50.22 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Dec 2023 00:50:22 -0800 (PST) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=pass header.i=@kernkonzept.com header.s=mx1 header.b=Gkxvo6FG; arc=pass (i=1); spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernkonzept.com Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 9163F3857B88 for ; Mon, 18 Dec 2023 08:50:22 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mx.kernkonzept.com (serv1.kernkonzept.com [IPv6:2a01:4f8:1c1c:b490::2]) by sourceware.org (Postfix) with ESMTPS id 0B6723858424 for ; Mon, 18 Dec 2023 08:49:59 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 0B6723858424 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=kernkonzept.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=kernkonzept.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 0B6723858424 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a01:4f8:1c1c:b490::2 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1702889400; cv=none; b=gi2+FOKM62RHqcgH+qMAtoF7L/Q7MiNp/vE5knGYZWu9XKIc8vhbk9kGx9X2jpwzofzojQtyv9h1NrZHhR1+RNCpbzY9szHuiKGSSD4IXS/BuwMOA9hDvhgzgKfNmbcfL+ivyCzfsF9kgOfTZ6c3CLQzbVnICAI54pcUIgS7mEo= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1702889400; c=relaxed/simple; bh=JzxIxIgBc0BZhE443h/fSkGqOnRLNbOdeZH1bWIpqps=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=tyAzuwIm7DoMfY7dViN6f1syblMEe1i3S8ly7WZZz/ebNM4fb552xDpboQFe+kqLuk+WbphAGVtwiaQ0W8fU83WjDQEUHo8wjjDvGifBmS0YEAbhsBa5FzIkS/Mvyq1Pqlz5KTwLuIQFs5G7Q+tlYGUuZsr8qUfU5GDMz9cvtuY= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=kernkonzept.com; s=mx1; h=Content-Type:MIME-Version:Message-ID:Date:Subject :To:From:Content-Transfer-Encoding:References:In-Reply-To:Cc:Reply-To: Content-ID:Content-Description; bh=4w4irFjMsSBB1LCR34Et6ZwO2Y6rqvw+W1RKIdVVunQ=; b=Gkxvo6FGi/CKyoazd1vqZn8R7d mslSNbSzd+P1TnZDirWTdntdmkQMhDk3aurEdEgvjccsdRqTn9+2mW8XeKtPN1rXbZpK7OX3ZJ8en ICZIPWMb6NgJvvPjvubf5MVItv9Jh/3RxlwxYJloELWe1im6s5FaQfhRIcfBXm7QWNnW6xrVMb7TI VrsYPmfjAcWiMqWgQb0yJZR5zmfFy2CXa55+ean1u2UvKbevd4zlvcw1fAP3pI/DWpijZTFjPCkwV 1qWadeljz6RTkgjmfXsMUuVdkTWmp92AaK9hc6tlHcnWhl2aIG0149RcE+Y6DNoWXqrDRDl4SgdsS Q/e6dRGQ==; Received: from [10.22.3.218] (helo=localhost) by mx.kernkonzept.com with esmtpsa (TLS1.3:ECDHE_SECP256R1__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim 4.96) id 1rF9K1-00Curk-0e for gcc-patches@gcc.gnu.org; Mon, 18 Dec 2023 09:49:57 +0100 User-agent: mu4e 1.10.8; emacs 29.1 From: Martin =?utf-8?q?K=C3=BCttler?= To: gcc-patches@gcc.gnu.org Subject: Patch: Remove unneeded double operation in libstdc++-v3/src/c++17/fs_path.cc Date: Mon, 18 Dec 2023 09:36:37 +0100 Message-ID: <878r5r99or.fsf@calavera> MIME-Version: 1.0 X-Spam-Status: No, score=-13.8 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, 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+ouuuleilei=gmail.com@gcc.gnu.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1785608979232434158 X-GMAIL-MSGID: 1785608979232434158 This is a small change to libstdc++ which does not change any behavior. This change has two, ihmo positive, implications: - The implicit conversion from double to int is avoided (Avoiding a warning). - No floating point number is used at all, which could be significant in some scenarios. ------------ diff --git a/libstdc++-v3/src/c++17/fs_path.cc b/libstdc++-v3/src/c++17/fs_path.cc index d65b5482e8b..b47ed0aa7aa 100644 --- a/libstdc++-v3/src/c++17/fs_path.cc +++ b/libstdc++-v3/src/c++17/fs_path.cc @@ -447,8 +447,9 @@ path::_List::reserve(int newcap, bool exact = false) if (curcap < newcap) { - if (!exact && newcap < int(1.5 * curcap)) - newcap = 1.5 * curcap; + const int nextcap = curcap + curcap / 2; + if (!exact && newcap < nextcap) + newcap = nextcap; void* p = ::operator new(sizeof(_Impl) + newcap * sizeof(value_type)); std::unique_ptr<_Impl, _Impl_deleter> newptr(::new(p) _Impl{newcap});