X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=opendaylight%2Fmd-sal%2Fsal-inmemory-datastore%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fmd%2Fsal%2Fdom%2Fstore%2Fimpl%2FResolveDataChangeState.java;h=3db4115af67908bed3c4edfcfbb2d91cdae3baae;hb=dd281c0e33267296ad3babbffd03e1122cdb127e;hp=e18b632275b88f51e713468f1bf1ca7de6c24dfb;hpb=9c3466c3df8b422440aa5213f214e8b83c798d5c;p=controller.git diff --git a/opendaylight/md-sal/sal-inmemory-datastore/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/ResolveDataChangeState.java b/opendaylight/md-sal/sal-inmemory-datastore/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/ResolveDataChangeState.java index e18b632275..3db4115af6 100644 --- a/opendaylight/md-sal/sal-inmemory-datastore/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/ResolveDataChangeState.java +++ b/opendaylight/md-sal/sal-inmemory-datastore/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/ResolveDataChangeState.java @@ -175,12 +175,25 @@ final class ResolveDataChangeState { if (!inheritedOne.isEmpty()) { return true; } - // Have SUBTREE listeners - if (!Iterables.isEmpty(inheritedSub)) { - return true; + + /* + * Have SUBTREE listeners + * + * This is slightly magical replacement for !Iterables.isEmpty(inheritedSub). + * It relies on the logic in child(), which gives us the guarantee that when + * inheritedSub is not a Collection, it is guaranteed to be non-empty (which + * means we need to process). If it is a collection, we still need to check + * it for emptiness. + * + * Unlike Iterables.isEmpty() this code does not instantiate any temporary + * objects and is thus more efficient. + */ + if (inheritedSub instanceof Collection) { + return !((Collection) inheritedSub).isEmpty(); } - return false; + // Non-Collection => non-empty => have to process + return true; } /**