From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTPS id 4CFA1385840F for ; Fri, 24 Feb 2023 11:46:54 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 4CFA1385840F Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1677239213; h=from:from:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:in-reply-to:in-reply-to: references:references; bh=AHA8LLUjJQp46HNw/ZVZBvl/Qg73iEimy7bOu93qm8I=; b=T2OgCRVOT/mHUH69DLvyaOs3SsbeZ2rZHeoePJu7A9H+HEERcfJeq9cO8LvUDKk96d0gVT 9KRwPOV8CSg+r/2hyhl/X7mYI4Uq1PNasq92Ks3qkssHuW5aJ7ESIZmu+Z7VdrAv74wsim 1cAN04W+Z/o4Sm7Yz3Vbk8HmAmOhn8Q= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-44-1jUTIUnuPHW07eCYrmggqA-1; Fri, 24 Feb 2023 06:46:50 -0500 X-MC-Unique: 1jUTIUnuPHW07eCYrmggqA-1 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 43F351802CE4; Fri, 24 Feb 2023 11:46:50 +0000 (UTC) Received: from tucnak.zalov.cz (unknown [10.39.192.62]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 08033492C3E; Fri, 24 Feb 2023 11:46:49 +0000 (UTC) Received: from tucnak.zalov.cz (localhost [127.0.0.1]) by tucnak.zalov.cz (8.17.1/8.17.1) with ESMTPS id 31OBklpf863949 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Fri, 24 Feb 2023 12:46:47 +0100 Received: (from jakub@localhost) by tucnak.zalov.cz (8.17.1/8.17.1/Submit) id 31OBkk9w863948; Fri, 24 Feb 2023 12:46:46 +0100 Date: Fri, 24 Feb 2023 12:46:46 +0100 From: Jakub Jelinek To: Richard Biener Cc: gcc-patches@gcc.gnu.org Subject: Re: [PATCH 1/2] Change vec<, , vl_embed>::m_vecdata refrences into address () Message-ID: Reply-To: Jakub Jelinek References: <20230224113245.9645013246@imap2.suse-dmz.suse.de> MIME-Version: 1.0 In-Reply-To: <20230224113245.9645013246@imap2.suse-dmz.suse.de> X-Scanned-By: MIMEDefang 3.1 on 10.11.54.9 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=us-ascii Content-Disposition: inline X-Spam-Status: No, score=-3.3 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_NONE,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: On Fri, Feb 24, 2023 at 12:32:45PM +0100, Richard Biener via Gcc-patches wrote: > --- a/gcc/vec.h > +++ b/gcc/vec.h > @@ -614,7 +614,7 @@ public: > T *bsearch (const void *key, int (*compar)(const void *, const void *)); > T *bsearch (const void *key, > int (*compar)(const void *, const void *, void *), void *); > - unsigned lower_bound (T, bool (*)(const T &, const T &)) const; > + unsigned lower_bound (const T &, bool (*)(const T &, const T &)) const; Missing space after (*) while you're there. > @@ -929,7 +929,7 @@ vec::iterate (unsigned ix, T *ptr) const > { > if (ix < m_vecpfx.m_num) > { > - *ptr = m_vecdata[ix]; > + *ptr = address()[ix]; Missing space before (). > @@ -1118,7 +1118,7 @@ inline void > vec::unordered_remove (unsigned ix) > { > gcc_checking_assert (ix < length ()); > - m_vecdata[ix] = m_vecdata[--m_vecpfx.m_num]; > + address ()[ix] = address ()[--m_vecpfx.m_num]; > } As address () is used twice here, can't we stick it into a temporary and use twice then? > @@ -1249,8 +1249,11 @@ vec::contains (const T &search) const > { > unsigned int len = length (); > for (unsigned int i = 0; i < len; i++) > - if ((*this)[i] == search) > - return true; > + { > + const T *slot = &address ()[i]; > + if (*slot == search) > + return true; Similarly, can't we do address () once before the loop into a temporary? > template > unsigned > -vec::lower_bound (T obj, bool (*lessthan)(const T &, const T &)) > +vec::lower_bound (const T &obj, > + bool (*lessthan)(const T &, const T &)) ) ( while you're at it. Otherwise LGTM. Jakub