From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by sourceware.org (Postfix) with ESMTPS id EE9D83858D33 for ; Fri, 6 Jan 2023 16:50:45 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org EE9D83858D33 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=suse.cz Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=suse.cz Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 8606C336F7; Fri, 6 Jan 2023 16:50:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1673023844; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Ru35P+OaGYSD4BqQvWEKQZFJ05GrvP+aRrEC7YLWJEI=; b=kIl5rL+Ov28NUMrl0rygqs2pw+pZghY0fUw+S1mJ5Oduz4c43Bc12guC0DKgl8XLSLvqs6 lypoNmx6ttWYTD5zPGyOX41iKYLnw/cE1m2jWmGqmlB00qOf9PqYMqJBPirtLEMBGXJzcq fBWDfyL/v0cIr1ECImEbPjCL07WIetA= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1673023844; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Ru35P+OaGYSD4BqQvWEKQZFJ05GrvP+aRrEC7YLWJEI=; b=1w0my0mJ2PDVWJ67EOkB5Y9LzK6zA4sn6QG98+sFs1ZY3HeX0v05bKSCsbTj6N+osQbmzz 9GnlkIN32XxPaYBg== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 786A1139D5; Fri, 6 Jan 2023 16:50:44 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id LsATHWRRuGOSPgAAMHmgww (envelope-from ); Fri, 06 Jan 2023 16:50:44 +0000 From: Martin Jambor To: Martin =?utf-8?Q?Li=C5=A1ka?= , GCC Patches Cc: Jan Hubicka , Jan Hubicka Subject: Re: [PATCH] ipa: Sort ipa_param_body_adjustments::m_replacements (PR 108110) In-Reply-To: <252552ce-961e-b10a-976b-4b598b907f7e@suse.cz> References: <252552ce-961e-b10a-976b-4b598b907f7e@suse.cz> User-Agent: Notmuch/0.37 (https://notmuchmail.org) Emacs/28.2 (x86_64-suse-linux-gnu) Date: Fri, 06 Jan 2023 17:50:44 +0100 Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-5.8 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS,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: Hi, On Fri, Jan 06 2023, Martin Li=C5=A1ka wrote: > Hi Martin > >> + key.unit_offset =3D unit_offset; >> + ipa_param_body_replacement *res >> + =3D std::lower_bound (m_replacements.begin (), m_replacements.end (= ), key, >> + [] (const ipa_param_body_replacement &elt, >> + const ipa_param_body_replacement &val) >> + { >> + if (DECL_UID (elt.base) < DECL_UID (val.base)) >> + return true; >> + if (DECL_UID (elt.base) > DECL_UID (val.base)) >> + return false; >> + if (elt.unit_offset < val.unit_offset) >> + return true; >> + return false; >> + }); > > I'm curious if we can re-use compare_param_body_replacement as the introd= uced > lambda does a very similar thing, right? > Not directly, the qsort callback returns an integer that can be either negative, positive or zero but the lower_bound returns only true or false (the semantics is that it returns the first element for which it returns false). Plus one takes parameters which are pointer and other needs references. So I was lazy and just came up with a similar comparator lambda. But sure, I can call the qsort comparator from it, which I guess makes sense at least for consistency. I'll adjust the patch. Thanks, Martin