From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-qv1-xf2a.google.com (mail-qv1-xf2a.google.com [IPv6:2607:f8b0:4864:20::f2a]) by sourceware.org (Postfix) with ESMTPS id 8DC683971C1B; Tue, 17 Aug 2021 13:40:49 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 8DC683971C1B Received: by mail-qv1-xf2a.google.com with SMTP id bl13so11158833qvb.5; Tue, 17 Aug 2021 06:40:49 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=bcMtWxv7UIADYdmrS3oYGvgV1WiYvgMoKyCH19wtNfs=; b=VlMcjAy3Acd5fa3F61RwDxg8DGD+3MdEXEheSqHrOCi4xhk1Ccm273/HG0OorwLoIN Gq9R+QUfsLoYA7XP6gTEwUlT/5BiO4/QDN32xgEuUUbxbmy7cPnS3rYtm1q82ZfvjvPN CEQnnNiSfnl5L1emYqL96kAeodYs0eNk5uJasuQLQsVcvq1etfEEedyX5NcrC8NHOQHT 9OwYRUDx/8w/Et5dZkzCxJtOVjpo7P8Rn12VOD2qAaXWuo37Erj72+S3EHUohs/nWrL+ 9QTiNEhZ6OxFvyzFBG6HBxkC5UuhYShbpCE4LbkQUG3GinyXuD07dhFBxJBMO2KIIbr8 RBTw== X-Gm-Message-State: AOAM533A35YHv0UE3kOn4XECOl0zksabwC4MHqQ8sUKKqU6vIgVjRdHv +mmRVUi6+mrdTnMN9lIErU/4xYjZaWE4y6Z6LJ8= X-Google-Smtp-Source: ABdhPJxm4sl3MHh5pDnc6OYT/QREc8jx989KtH7P+MIcu8G/Pe/eATIOheMvYnolHjRNt/clUCw4G9F76C0QHRaqt9U= X-Received: by 2002:a05:6214:7b1:: with SMTP id v17mr3351214qvz.20.1629207649259; Tue, 17 Aug 2021 06:40:49 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Antony Polukhin Date: Tue, 17 Aug 2021 16:40:37 +0300 Message-ID: Subject: Re: [PATCH] Optimize seed_seq construction To: Jonathan Wakely Cc: "libstdc++" , gcc-patches List Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-3.0 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) 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: Tue, 17 Aug 2021 13:40:55 -0000 =D0=B2=D1=82, 17 =D0=B0=D0=B2=D0=B3. 2021 =D0=B3. =D0=B2 16:37, Jonathan Wa= kely : <...> > Thanks, this is a nice improvement. We can avoid tag dispatching to > make it simpler though: > > @@ -3248,6 +3249,9 @@ namespace __detail > template > seed_seq::seed_seq(_InputIterator __begin, _InputIterator __end) > { > + if _GLIBCXX17_CONSTEXPR > (__is_random_access_iter<_InputIterator>::value) > + _M_v.reserve(std::distance(__begin, __end)); > + > for (_InputIterator __iter =3D __begin; __iter !=3D __end; ++__iter= ) > _M_v.push_back(__detail::__mod __detail::_Shift::__value>(*__iter= )); > > The call to std::distance is well-formed for input iterators, but we > won't actually call it unless we have random access iterators. > > Unless you see a problem with this that I'm missing, I'll go with that ve= rsion. Looks much better. Thanks! --=20 Best regards, Antony Polukhin