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.

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 via email to