[Lldb-commits] [lldb] r331415 - [NSDictionary] Simplify the formatter. NFCI.

Jason Molenda via lldb-commits lldb-commits at lists.llvm.org
Wed May 2 17:12:47 PDT 2018

> On May 2, 2018, at 4:58 PM, Davide Italiano <dccitaliano at gmail.com> wrote:
> On Wed, May 2, 2018 at 4:56 PM, Davide Italiano <dccitaliano at gmail.com> wrote:
>> On Wed, May 2, 2018 at 4:51 PM, Jason Molenda via lldb-commits
>> <lldb-commits at lists.llvm.org> wrote:
>>> Is this really simpler?  We could write it
>>> if (name == g_zero)
>>>  return 0;
>>> else
>>>  return UINT32_MAX;
>>> or we could do it that way, or it could be done the way it was originally written.
>>> tbh it seems like a style choice, and whoever wrote it originally may have preferred it being expressed that way.  I can understand that you prefer it be expressed this way - but it's not actually any better or more readable, is it?  Certainly the compiler is going to turn any variation we can come up with into the same instructions.
>> Oh, I guess I should've said "make this code shorter" or something :)
>> We end up preferring ternary in llvm whenever possible, and I just
>> followed what was used there.
>> I largely agree it's a stylistic choice, FWIW.
> Also, I don't necessarily mind reverting this, as long as we agree on
> a style to follow.

Personally I think if-else is a lot easier to read than the ternary operator here.  The original author thought that 

if (name == g_zero)
  return 0;

return UINT32_max;

was more readable than if-else - we all have personal preferences.  I think the llvm style guides may have picked, imo, the least readable of the three alternatives.  I won't be making changes to the codebase like this, but its up to each of us to do what we think improves the project the most, so.

More information about the lldb-commits mailing list