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

Jason Molenda via lldb-commits lldb-commits at lists.llvm.org
Wed May 2 16:51:51 PDT 2018


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.



> On May 2, 2018, at 4:36 PM, Davide Italiano via lldb-commits <lldb-commits at lists.llvm.org> wrote:
> 
> Author: davide
> Date: Wed May  2 16:36:07 2018
> New Revision: 331415
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=331415&view=rev
> Log:
> [NSDictionary] Simplify the formatter. NFCI.
> 
> Modified:
>    lldb/trunk/source/Plugins/Language/ObjC/NSDictionary.cpp
> 
> Modified: lldb/trunk/source/Plugins/Language/ObjC/NSDictionary.cpp
> URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Language/ObjC/NSDictionary.cpp?rev=331415&r1=331414&r2=331415&view=diff
> ==============================================================================
> --- lldb/trunk/source/Plugins/Language/ObjC/NSDictionary.cpp (original)
> +++ lldb/trunk/source/Plugins/Language/ObjC/NSDictionary.cpp Wed May  2 16:36:07 2018
> @@ -667,11 +667,7 @@ lldb_private::formatters::NSDictionary1S
> size_t lldb_private::formatters::NSDictionary1SyntheticFrontEnd::
>     GetIndexOfChildWithName(const ConstString &name) {
>   static const ConstString g_zero("[0]");
> -
> -  if (name == g_zero)
> -    return 0;
> -
> -  return UINT32_MAX;
> +  return name == g_zero ? 0 : UINT32_MAX;
> }
> 
> size_t lldb_private::formatters::NSDictionary1SyntheticFrontEnd::
> 
> 
> _______________________________________________
> lldb-commits mailing list
> lldb-commits at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits



More information about the lldb-commits mailing list