Home | About | Sematext search-lucene.com search-hadoop.com
 Search Hadoop and all its subprojects:

Switch to Plain View
Accumulo >> mail # dev >> Non Short Circuit Logic


+
David Medinets 2012-09-12, 16:29
+
John Vines 2012-09-12, 17:22
Copy link to this message
-
Re: Non Short Circuit Logic
Without looking at SystemPermisison.values(), I don't know if John is
correct. If he's not, to get a speed improvement via short-circuiting,
you'd want to make the null check the first check in the conditional
because its faster than the method call.

On Wed, Sep 12, 2012 at 1:22 PM, John Vines <[EMAIL PROTECTED]> wrote:
> Judging from that code, p is never null so that second case is unnecessary.
>
> Sent from my phone, so pardon the typos and brevity.
> On Sep 12, 2012 12:29 PM, "David Medinets" <[EMAIL PROTECTED]> wrote:
>
>> The if statement belows uses a single & instead of &&. Therefore it is
>> not using short-circut logic. This seems like a typo. Does anyone
>> object if I change the '&' to '&&'?
>>
>>     String delim = "";
>>     shellState.getReader().printString("System permissions: ");
>>     for (SystemPermission p : SystemPermission.values()) {
>>       if
>> (shellState.getConnector().securityOperations().hasSystemPermission(user,
>> p) & p != null) {
>>         shellState.getReader().printString(delim + "System." + p.name());
>>         delim = ", ";
>>       }
>>     }
>>     shellState.getReader().printNewline();
>>
+
David Medinets 2012-09-12, 20:54
+
John Vines 2012-09-12, 21:00