From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp-out2.suse.de (smtp-out2.suse.de [IPv6:2001:67c:2178:6::1d]) by sourceware.org (Postfix) with ESMTPS id 9D6753858D1E for ; Mon, 9 Jan 2023 15:19:30 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 9D6753858D1E Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=suse.cz Authentication-Results: sourceware.org; spf=fail 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-out2.suse.de (Postfix) with ESMTPS id 6C2691FF4C; Mon, 9 Jan 2023 15:19:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1673277569; 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=QHNRrEjTjZgh7ckitQeiJoAzdSnHZL+QVindU2L3o9o=; b=oidtUJQfrBouKxDaR+dWQotqyAADF37gWucKiWnxyzCTb9nkXQ801XKgDOA3EMRtJo4tqL bfAhEzS10uMSoEt6ryyeA3Gz8OiDPD2B7o2Zb8qiauHRSaagvs0px1f9BF6Xt/RoUkuCPM jwGT8RIWNP0Q+r1u0rmp5aXOQiTDGo0= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1673277569; 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=QHNRrEjTjZgh7ckitQeiJoAzdSnHZL+QVindU2L3o9o=; b=8sBKcLDgzwuU1reYgmz5suHtN9J1ZFjei+j5Pr3lu1+oHi/854qUr6vNvodnvrOXzUrvN/ HAkm5wnibav/55DA== 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 4B9F8134AD; Mon, 9 Jan 2023 15:19:29 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id TR/2EIEwvGOFSwAAMHmgww (envelope-from ); Mon, 09 Jan 2023 15:19:29 +0000 Message-ID: Date: Mon, 9 Jan 2023 16:19:28 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.6.1 Subject: Re: [PATCH] ipa: Sort ipa_param_body_adjustments::m_replacements (PR 108110) Content-Language: en-US To: Martin Jambor , GCC Patches Cc: Jan Hubicka , Jan Hubicka References: <252552ce-961e-b10a-976b-4b598b907f7e@suse.cz> From: =?UTF-8?Q?Martin_Li=c5=a1ka?= In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-5.6 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A,SPF_HELO_NONE,SPF_SOFTFAIL,TXREP autolearn=no 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 1/6/23 17:50, Martin Jambor wrote: > Hi, > > On Fri, Jan 06 2023, Martin Liška wrote: >> Hi Martin >> >>> + key.unit_offset = unit_offset; >>> + ipa_param_body_replacement *res >>> + = 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 introduced >> 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. Hi. I see, so leaving that up to you if you want to adjust it or not. OK for both versions of the patch. Cheers, Martin > > 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