public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: "Martin Liška" <mliska@suse.cz>
To: Martin Jambor <mjambor@suse.cz>, GCC Patches <gcc-patches@gcc.gnu.org>
Cc: Jan Hubicka <jh@suse.cz>, Jan Hubicka <hubicka@ucw.cz>
Subject: Re: [PATCH] ipa: Sort ipa_param_body_adjustments::m_replacements (PR 108110)
Date: Mon, 9 Jan 2023 16:19:28 +0100	[thread overview]
Message-ID: <fe50a45d-639b-4998-74d6-1457ded80a00@suse.cz> (raw)
In-Reply-To: <ri6v8ljk3ob.fsf@suse.cz>

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


      reply	other threads:[~2023-01-09 15:19 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-05 16:46 Martin Jambor
2023-01-06 11:51 ` Martin Liška
2023-01-06 16:50   ` Martin Jambor
2023-01-09 15:19     ` Martin Liška [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=fe50a45d-639b-4998-74d6-1457ded80a00@suse.cz \
    --to=mliska@suse.cz \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=hubicka@ucw.cz \
    --cc=jh@suse.cz \
    --cc=mjambor@suse.cz \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).