Arik Hadas has uploaded a new change for review. Change subject: core: improve post zero check ......................................................................
core: improve post zero check This patch improves the check whether to use post zero or not when removing memory state images using MemoryImageRemover class: instead of filtering the list of disks to get all the disks which are marked with "wipe after delete" and then check if the list is not empty, we check whether one of the disks in the list is marked with "wipe after delete". This change has several benefits: 1. we don't have to go over all the items in the list everytime (only in the worst case, if no such disk exists in the list) 2. we don't need to create new list 3. the code is shorter and is more intuitive Change-Id: Id78a5b74748f5c174fd0fba70c95c40b66ff247f Signed-off-by: Arik Hadas <[email protected]> --- M backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/memory/MemoryImageRemover.java 1 file changed, 6 insertions(+), 10 deletions(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/24/16824/1 diff --git a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/memory/MemoryImageRemover.java b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/memory/MemoryImageRemover.java index 30fa1cc..545dfe2 100644 --- a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/memory/MemoryImageRemover.java +++ b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/memory/MemoryImageRemover.java @@ -16,8 +16,6 @@ import org.ovirt.engine.core.compat.Guid; import org.ovirt.engine.core.dal.dbbroker.DbFacade; import org.ovirt.engine.core.utils.GuidUtils; -import org.ovirt.engine.core.utils.linq.LinqUtils; -import org.ovirt.engine.core.utils.linq.Predicate; public class MemoryImageRemover { @@ -123,17 +121,15 @@ protected boolean isPostZero() { if (cachedPostZero == null) { - // get all vm disks in order to check post zero - if one of the - // disks is marked with wipe_after_delete + // check if one of the disks is marked with wipe_after_delete cachedPostZero = - LinqUtils.filter( - getDbFacade().getDiskDao().getAllForVm(vm.getId()), - new Predicate<Disk>() { + getDbFacade().getDiskDao().getAllForVm(vm.getId()).contains( + new Object() { @Override - public boolean eval(Disk disk) { - return disk.isWipeAfterDelete(); + public boolean equals(Object obj) { + return ((Disk) obj).isWipeAfterDelete(); } - }).size() > 0; + }); } return cachedPostZero; } -- To view, visit http://gerrit.ovirt.org/16824 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Id78a5b74748f5c174fd0fba70c95c40b66ff247f Gerrit-PatchSet: 1 Gerrit-Project: ovirt-engine Gerrit-Branch: master Gerrit-Owner: Arik Hadas <[email protected]> _______________________________________________ Engine-patches mailing list [email protected] http://lists.ovirt.org/mailman/listinfo/engine-patches
