Moti Asayag has posted comments on this change.

Change subject: core: Add cinder helper method for Cinder disks
......................................................................


Patch Set 4:

(1 comment)

https://gerrit.ovirt.org/#/c/40675/4/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/storage/CINDERStorageHelper.java
File 
backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/storage/CINDERStorageHelper.java:

Line 142: 
Line 143:     public static SubjectEntity[] getStorageEntities(List<CinderDisk> 
cinderDisks) {
Line 144:         List<SubjectEntity> storageSubjects = new ArrayList<>();
Line 145:         for (final CinderDisk cinderDisk : cinderDisks) {
Line 146:             SubjectEntity subjectStorage = 
LinqUtils.firstOrNull(storageSubjects, new Predicate<SubjectEntity>() {
if the intention of thid block is to prevent duplications in the generated 
list, you can simplify it by using:
   Map<Guid, CinderDisk> disks = Entities.businessEntitiesById(cinderDisks);

That guarantees that each ID appears only once in the map.
Then you can iterate over its.

Or use 
   new HashSet<>(Entities.getIds(cinderDisks));

and iterate over it.

either way, it should be more efficient than the suggested solution and more 
readable :-)
Line 147:                 @Override
Line 148:                 public boolean eval(SubjectEntity storageSubject) {
Line 149:                     return 
storageSubject.getEntityId().equals(cinderDisk.getStorageIds().get(0));
Line 150:                 }


-- 
To view, visit https://gerrit.ovirt.org/40675
To unsubscribe, visit https://gerrit.ovirt.org/settings

Gerrit-MessageType: comment
Gerrit-Change-Id: I59afc1d6814ccdf343615322f758bd473482a296
Gerrit-PatchSet: 4
Gerrit-Project: ovirt-engine
Gerrit-Branch: master
Gerrit-Owner: Maor Lipchuk <mlipc...@redhat.com>
Gerrit-Reviewer: Daniel Erez <de...@redhat.com>
Gerrit-Reviewer: Jenkins CI
Gerrit-Reviewer: Maor Lipchuk <mlipc...@redhat.com>
Gerrit-Reviewer: Moti Asayag <masa...@redhat.com>
Gerrit-Reviewer: automat...@ovirt.org
Gerrit-HasComments: Yes
_______________________________________________
Engine-patches mailing list
Engine-patches@ovirt.org
http://lists.ovirt.org/mailman/listinfo/engine-patches

Reply via email to